Announcement Announcement Module
Collapse
No announcement yet.
Update single table in Hibernate Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Update single table in Hibernate

    I'm a newbie.

    i have the following tables:
    Person
    person_oid (PK)
    height
    weight
    country_oid (FK)
    ...

    Country
    country_oid (PK)
    country_name
    ...

    so I have the following object:
    Person
    personOid
    height
    weight
    Country

    if I only want to update height and weight, I still have to retrieve Country object and set to Person object, then call saveOrUpdate(person). Is there anyway I can update the Person object without issue a sql to get the Country object?

    Thanks in advance!

  • #2
    Why would you need to have the country? Make sure that your mappings are correct and make lazy what can be lazy. Hibernate is smart enough to now if it needs to update a country then.

    Also before updating an instance you probably retrieve it from the database, update its properties, and store it. If you do it that way, you don't have the problems you mentioned.

    Comment


    • #3
      You probably don't even need to save the item, all you need to do is retrieve it and change the values.
      http://www.hibernate.org/hib_docs/v3...ate-transitive
      Last edited by karldmoore; Aug 29th, 2007, 12:09 PM.

      Comment

      Working...
      X