Re: hibernate "null id in entry" exception



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




Georg J. Stach wrote:

aj wrote:


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
.



Relevant Pages

  • Re: No Administrator login after hibernate
    ... If I press the toshiba hotkey to hibernate and the suspend ... > hibernated while I was logged in as Administrator. ... > the screen that normally allows me to login as Administrator. ...
    (microsoft.public.windowsxp.configuration_manage)
  • Re: No Administrator login after hibernate
    ... If I press the toshiba hotkey to hibernate and the suspend ... > hibernated while I was logged in as Administrator. ... > the screen that normally allows me to login as Administrator. ...
    (microsoft.public.windowsxp.security_admin)
  • Face recognition app changed MSGINA.DLL - Classic login only
    ... It broke my login screen and FUS, and I could not Hibernate either. ... original for the normal login screens. ...
    (microsoft.public.windowsxp.general)
  • Re:Power Options and Log On
    ... Turn off the Welcome Screen and you will get the normal window and you will have to press Ctrl+Alt+Del to login. ... Note that this has to be password protected or else a simple enter will enable logging in. ... how can I ad the hibernate ... Hibernate tab, ...
    (microsoft.public.windowsxp.basics)