Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

which one is preferred between and session.persist()

Kumar Raja
Ranch Hand
Posts: 547
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:

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