Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / Databases / June 2005

Tip: Looking for answers? Try searching our database.

hibernate "null id in entry" exception

Thread view: 
aj - 24 Jun 2005 17:06 GMT
Hibernate 2.1.6
DB2 8.1
Java 1.5

I am trying to debug a Swing/Hibernate database app that was written
for us by a (now departed) contractor.

We are getting this exception when we save (ie session.saveOrUpdate()):
  net.sf.hibernate.AssertionFailure: null id in entry (don't flush the
  Session after an exception occurs)

It occurs pretty consistently, but not in the same spot.  What seems to
cause it one time will work fine another time. I'm thinking that perhaps
it is non-deterministic.

Can anyone point me in the right direction or offer any advice?  Is
hibernate attempting to insert something into the database that does
not have it's identity column set?

TIA
Allen
Georg J. Stach - 24 Jun 2005 19:34 GMT
> Can anyone point me in the right direction or offer any advice?  Is
> hibernate attempting to insert something into the database that does
> not have it's identity column set?

The best way for finding that out is to start debugging your application :-)
As far as I remember I got this error after having tried to insert an object
which really had "null" for its ID.

I think it's a deterministic issue.
Keep us informed.

PS: Doesn't your DB raise a not-null-constraint-violation?

--
Bye
Georg
aj - 24 Jun 2005 20:40 GMT
I don't know if it means a database id, or an internal hibernate id.
I have DB2 identity columns in my tables that are named "id".
Because they are identity columns, DB2 fills in the value at insert
time, and hibernate should know this (I've indicated so in my mapping).

Looking at my code, I see that it is using a single session, but the
developer used session.save() and sometimes session.saveOrUpdate(),
depending on whether session.contains(Object).  Is this a bad idea?

I'm confused about how or whether to use session.save() or
session.saveOrUpdate().

Lets say I have a persistent client instance/bean.  In my mapping I
have indicated that the client bean has a set of logins (a client
can have many logins), so I have indicated <one-to-many>.  So there
is also a persistent set of logins associated w/ the client.

Let's say that I create a new Login, and I fill in the appropriate
FK in that bean relating to the client PK, and add it to the logins
set.  How do I properly persist that new Login?  Do I:
  session.save( ), passing the Client bean
  session.save( ), passing the Login set
  session.save( ), passing the new Login bean

As I understand it, if I am using a single session, I can just ignore
session.save() altogether and just let Transaction.commit() do all
the work.  Is this a better approach?

aj

>>Can anyone point me in the right direction or offer any advice?  Is
>>hibernate attempting to insert something into the database that does
[quoted text clipped - 12 lines]
> Bye
>  Georg


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.