Re: hibernate "null id in entry" exception
- From: aj <ronald@xxxxxxxxxxxxx>
- Date: Fri, 24 Jun 2005 15:40:54 -0400
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
.
- References:
- hibernate "null id in entry" exception
- From: aj
- Re: hibernate "null id in entry" exception
- From: Georg J. Stach
- hibernate "null id in entry" exception
- Prev by Date: Re: hibernate "null id in entry" exception
- Next by Date: Re: JDBC and Access relationships
- Previous by thread: Re: hibernate "null id in entry" exception
- Index(es):
Relevant Pages
|
|