java - Hibernate- cascading option for one to many using spring HibernateTemplate -
in application, i'm having one-to-many relationship in have following requirements. example, take car- owner relationship. owner can have multiple cars, while 1 car can have 1 owner only.
- when save parent entity (owner) car collection in it, want car inserted automatically. same update well.
- when remove car objects collection & save, want removed car objects deleted database.
i tried following options in hibernate xml mapping:
inverse="false" fetch="select" cascade="all-delete-orphan" and inserted using
hibernatetemplate.persist() updated using
hibernatetemplate.merge() the update works well, insert not working properly.
can advice me exact cascade option & method use in saving & updating such scenario?
see 21.3. cascading life cycle here:
http://docs.jboss.org/hibernate/orm/3.3/reference/en/html/example-parentchild.html
Comments
Post a Comment