wood burning stoves
The moose likes Object Relational Mapping and the fly likes Hibernate Custom SQL - avoid Id being used Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Hibernate Custom SQL - avoid Id being used" Watch "Hibernate Custom SQL - avoid Id being used" New topic

Hibernate Custom SQL - avoid Id being used

sir proof

Joined: Aug 17, 2012
Posts: 1
Hi everybody,

I've got a lot of answers to my questions here, even if I never asked them. But now I'm fronting a serious problem:

We want to execute DML to the database with stored procedures. Hibernate offers the possibility to define with @SQLInsert, -update, -delete your own prepared statements, which uses hibernate to "generate" the insert, update etc. statements. e.g. I have the following class definition:

The problem is, that the id is generated by the procedure itself and should not be passed or generated by hibernate. But if the id is not used in the prepared statement I get a:

Because Hibernate tries to put the value of the id into the statement and does not find a place holder like ':id'.

The definition

does only have impact on non-key-properties, so that they where skipped.

Does anybody know this behavior and can help me out of this mess?

Thanks and bye
Bill Gorder

Joined: Mar 07, 2010
Posts: 1682

I don't deal with Stored Procedures much but I think you need to look at your @GeneratedValue. Take a look at this and see if it gets you on the right path


[How To Ask Questions][Read before you PM me]
I agree. Here's the link: http://aspose.com/file-tools
subject: Hibernate Custom SQL - avoid Id being used
It's not a secret anymore!