Forums Register Login

which one is preferred between session.save() and session.persist()

+Pie Number of slices to send: Send
Hi All,

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


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.

Thanks
Think of how stupid the average person is. And how half of them are stupider than that. But who reads this tiny ad?
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 1036 times.
Similar Threads
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
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 11:24:49.