-->
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.  [ 2 posts ] 
Author Message
 Post subject: Urgent -- One to Many Mapping Errors
PostPosted: Thu Feb 07, 2008 3:23 am 
Newbie

Joined: Thu Feb 07, 2008 2:26 am
Posts: 3
Update Mechanism in Hibernate

1. What is the session.Update or session.saveOrUpdate Mechanism in Hibernate ? Why are insert queries being executed when i say Update

2. I have a one to many mapping where i dont use certain columns of table in the mappings XML file , the BO corresponds to the XML File.When i say update Hibernate gives me a error stating that "ORA01400: CANNOT INSERT NULL INTO" a certain column which is present in the Table but not in the Mapping File or the BO??? The column referred is "Not Null" ...

How do i solve this issue???


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 07, 2008 9:01 am 
Beginner
Beginner

Joined: Mon Nov 19, 2007 4:40 pm
Posts: 46
1. update should simply update an existing instance where saveOrUpdate will save it if it doesn't exist or update it if it does. I do not know why update is executing an insert statement...

2. If I understand the problem correctly, you have a table with a column (which cannot be null) and a mapping file that excludes that column... When hibernate goes to insert data into that table, it will not pass anything in for that unmapped column, so by default your database will insert null. To prevent this from happening, you could define a default in your database. Alternatively, you could map the column to your object and provide a private setter/accessor method with a default value in your object.


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

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.