Hello
I have following problem,
If I call the find method from the hibernatetemplate of spring, I get an error when I
give a String[] with params.
Here some code:
Code:
String[] params = new String[1];
params[0] = userName;
List<AppUser> list = this.getHibernateTemplate().find(
"from AppUser where login = '?'", params);
That works:
Code:
List<AppUser> list = this.getHibernateTemplate().find(
"from AppUser where login = '"+username+"'");
If I try it with Arrays of Strings or Objects I get allways that Exception:
Code:
java.lang.IndexOutOfBoundsException: Remember that ordinal parameters are 1-based!
at org.hibernate.engine.query.ParameterMetadata.getOrdinalParameterDescriptor(ParameterMetadata.java:79)
at org.hibernate.engine.query.ParameterMetadata.getOrdinalParameterExpectedType(ParameterMetadata.java:85)
at org.hibernate.impl.AbstractQueryImpl.determineType(AbstractQueryImpl.java:421)
at org.hibernate.impl.AbstractQueryImpl.setParameter(AbstractQueryImpl.java:393)
at org.springframework.orm.hibernate3.HibernateTemplate$30.doInHibernate(HibernateTemplate.java:923)
at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:419)
at org.springframework.orm.hibernate3.HibernateTemplate.executeWithNativeSession(HibernateTemplate.java:374)
at org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:917)
at at.mt.mydata.dao.impl.UserDAOImpl.findUser(UserDAOImpl.java:21)
at at.mt.mydata.service.UserDetailsServiceImpl.loadUserByUsername(UserDetailsServiceImpl.java:23)
login is a String and mapped on that way:
Code:
@Column
public String getLogin() {
return login;
}
public void setLogin(String login) {
this.login = login;
}
Anybody an idea why I get allways that exception?
I tryed also to set the parameter 1-based on second place "params[1]",
but same exception