-->
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.  [ 2 posts ] 
Author Message
 Post subject: How do I set parameter in the where clause of Native sql?
PostPosted: Tue Nov 05, 2013 12:37 pm 
Newbie

Joined: Tue Nov 05, 2013 12:27 pm
Posts: 1
@javax.persistence.Entity
@Table(name = "EMPLOYEE", schema="ORA")
@SQLUpdate( sql= "update ORA.EMPLOYEE set NAME =? WHERE SEQ_ID =? and AGE < ? ")
class Person{
@Id
@Column(name = "SEQ_ID", length = 10, nullable = false, precision = 10, scale = 0)
private int id;
@Column(name = "AGE", length = 10, nullable = false, precision = 10, scale = 0)
private int age;
@Column(name = "NAME, length = 20, nullable = false)
private String name
}

Unit test case failed becuase of
Caused by: java.sql.SQLException: Missing IN or OUT parameter at index:: 3

How do I set the parameter for AGE? Does hibernate support this?

If I remove "and AGE < ?" condition in the SQLUPDATE it works.

Please update your suggestions.
Thanks


Top
 Profile  
 
 Post subject: Re: How do I set parameter in the where clause of Native sql?
PostPosted: Wed Nov 06, 2013 5:12 am 
Senior
Senior

Joined: Tue Oct 28, 2008 10:39 am
Posts: 196
As far as I understand @SQLUpdate it is used to define a user-specific update statement for EVERY update on that table. So you can call upper(?) on some fields or stuff like that. where-clause can only use the id-column.
Try to use a named query instead.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.