This week's book giveaway is in the Big Data forum.
We're giving away four copies of Elasticsearch in Action and have Radu Gheorghe & Matthew Lee Hinman on-line!
See this thread for details.
The moose likes Object Relational Mapping and the fly likes Check the id Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Elasticsearch in Action this week in the Big Data forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Check the id" Watch "Check the id" New topic

Check the id

Karel Vervaeke

Joined: Jul 20, 2004
Posts: 4
You're saying your id has unsaved-value=null,
you should make sure that the java-type of this id is nullable.
int id; // is not nullable.

You should either
1) specify an unsaved-value (e.g. -1) and make sure you set the id to -1 when constructing the persistent object.

2) use an Integer id; (default=null)

Karel Vervaeke

Joined: Jul 20, 2004
Posts: 4
Oops, that was supposed to be a reply to

I'm reposting it there right now, moderators, please delete this thread :/
I agree. Here's the link:
subject: Check the id