-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Create new ManyToOne Entities
PostPosted: Thu Jan 07, 2010 9:45 am 
Newbie

Joined: Tue Mar 03, 2009 6:37 am
Posts: 2
Hello!

Simple question:

I have two tables, table1 and table2.

table1 has one column table2id.

Now I want to create a new entry in table1.

Table1 t1 = new Table1();

Table2 just holds a status:

Table2 t2 = new Table2();
t2.setId(1);

t1.setTable2(t2);

...save...

Well, sometimes this scenario works, sometimes not. In my case it just works for table id 1.
If I set t2 to id 0 i get an exception
not-null property references a null or transient value: ...

How does hibernate check if the object exists ( for database integrity ). I donĀ“t want hibernate
to check if it exists because a) it exists and b) there should be no additional database call for getting
this second object every time.

Thanks a lot!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.