• Post Reply Bookmark Topic Watch Topic
  • New Topic

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

Kumar Raja
Ranch Hand
Posts: 550
Hibernate Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!