-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Custom SQL - Different parameter sequence (id & version)
PostPosted: Sun Aug 02, 2009 4:05 am 
Newbie

Joined: Sun Mar 23, 2008 6:23 pm
Posts: 3
Hi,

I'm using custom SQL annotations to do soft-deletes of my entities:
Quote:
@SQLDelete(sql = "UPDATE note SET deleted = (1) WHERE id = ? AND version = ?")

Because we use optimistic locking, the parameter sequence for the delete statement is 'id', 'version':
Quote:
INFO [STDOUT] Hibernate: delete from ListItem where id=? and version=?

Now, when delete is called through a cascade, the parameter sequence is different. It soly consists of 'id':
Quote:
INFO [STDOUT] Hibernate: delete from Note where id=?

In this case, I get an exeption based on my custom SQL expecting two parameters:
Quote:
ERROR [JDBCExceptionReporter] No value specified for parameter 2

The docs state that "The order of the positional parameters is vital, as they must be in the same sequence as Hibernate expects them"
If, for the same operation, Hibernate uses different parameter sequences, Is there a way to dynamicaly ajust the custom SQL?

Thank you!
- Chris


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.