-->
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.  [ 7 posts ] 
Author Message
 Post subject: need help in modifying static sql for update
PostPosted: Thu Feb 15, 2007 3:02 pm 
Newbie

Joined: Thu Feb 15, 2007 2:54 pm
Posts: 3
Hi,

would it be possible to add a custom "where clause" when we do a session.update(object)?

I see that adding a native sql in the xml mapping require one to explicitly map parameters wich i dont want. I want hibernate to generate the update sql and append my where clause with it.

Any help would be appreciated.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 15, 2007 3:34 pm 
Expert
Expert

Joined: Fri Aug 19, 2005 2:11 pm
Posts: 628
Location: Cincinnati
http://www.hibernate.org/hib_docs/v3/re ... erysql-cud

_________________
Chris

If you were at work doing this voluntarily, imagine what you'd want to see to answer a question.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 15, 2007 3:42 pm 
Newbie

Joined: Thu Feb 15, 2007 2:54 pm
Posts: 3
Chris,

As i said earlier if i use custom sql as mentioned in the link that u provided, i need to specify the complete update statements with bindings to parameters, which i dont want.
What i need is to reuse whatever update statement hibernate is generating but post append my where clause with it.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 15, 2007 3:57 pm 
Expert
Expert

Joined: Fri Aug 19, 2005 2:11 pm
Posts: 628
Location: Cincinnati
I've never tried it, but see if you can using an Interceptor and the onPrepareStatement(String sql) method

_________________
Chris

If you were at work doing this voluntarily, imagine what you'd want to see to answer a question.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 15, 2007 4:28 pm 
Expert
Expert

Joined: Fri Aug 19, 2005 2:11 pm
Posts: 628
Location: Cincinnati
better yet, just override the event listener for update if you're using hibernate 3.x.

copy the original source, then add your where clause

however, this might be more work than you think

_________________
Chris

If you were at work doing this voluntarily, imagine what you'd want to see to answer a question.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 15, 2007 4:47 pm 
Newbie

Joined: Thu Feb 15, 2007 2:54 pm
Posts: 3
Chris,

I have implemented an "save" listener and it is giving me a "SaveOrUpdateEvent". How would I use it to add my where clause?

thanks
maq


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 15, 2007 5:19 pm 
Expert
Expert

Joined: Fri Aug 19, 2005 2:11 pm
Posts: 628
Location: Cincinnati
don't know, never done anything like this before. Was hoping it made the preparedstatement available somewhere for ya.

_________________
Chris

If you were at work doing this voluntarily, imagine what you'd want to see to answer a question.


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

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.