Mark S. [http://community.jboss.org/people/dizzy0ny] created the discussion
"Hibernate Tools - How to handle updates to one-to-many property" To view the discussion, visit: http://community.jboss.org/message/573982#573982 -------------------------------------------------------------- Hi, I am using the JBoss Hibernate plug in for eclipse and attempting to reverse engineer my pojos from a mysql database. I have been able to do this with some success and i do see that the one-to-many and many-to-many properties are definied in the hbm files. What is happening however, is if i have pojo that represents a one to many relationship, and i make changes to both tables, only the single 'one' table is updated. For example, let's say i have a Person and a PersonAddress table that contain foreign key relationships. When i reverse engineer the Pojos from this database, what is created is a Person pojo which also contains a Set of PersonAddress: public Set<PersonAddress> getPersonAddresses() { return this.personAddresses; } public void setPersonAddresses(Set<PersonAddress> personAddresses) { this.personAddresses = personAddresses; } public void setPersonAddresses(Set<PersonAddress> personAddresses) { this.personAddresses = personAddresses; } If i update the Person.name and use hibernate to save that change, all works well. If i update the name and also add a new address however, the name changes, but the address is not added to the PersonAddress table. I am wondering if need to individually add the address first or if the above scenario should just work if i create a new PersonAddress, add it to the Person object using the setPersonAddresses method, and simply updating the Person object. thanks much any help regarding this, Mark -------------------------------------------------------------- Reply to this message by going to Community [http://community.jboss.org/message/573982#573982] Start a new discussion in JBoss Tools at Community [http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2128]
_______________________________________________ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user