Register / Login
this forum made possible by our volunteer staff, including ...
Roel De Nijs
Stephan van Hulst
Object Relational Mapping
which one is preferred between session.save() and session.persist()
posted 6 years ago
I have a one to one bidirectional mapping between Car and Registration.
I have used Many to One element on Registration side, with unique="true", instead of using One-One element.
When I say
registration.setCar(car) car.setRegistration(registration) session.save(registration) session.flush()
I get an exception
not-null property references a null or transient value: com.hibertut.beans.RegistrationDetails.car
But If i use session.persist(registration), it is inserting records in both car and registration table.
What is the difference? and why an exception in earlier case? Which one is preferred over other.
Also, how do I use one-one element instead of Many-one element in defining the mapping.
Boost this thread!
problems with Session.save()
Hibernate: Can someone verify my mapping configuration?
Hibernate One to One Example
Hbm files generated for One to One Mapping
How to persist objects having circular references using Hibernate