It's new to hibernate,using SSH framework,database is mysql 5,
I've got weird problem here.
attach DAO code:
UserMapDao.java(part):
attached the website login.jsp, & got an error:@Override public List queryUsers(Integer id,String name, String pass,String discrebtion) { String hql="from com.User u where u.name=? and u.pass=?"; String[] a=new String[]{name,pass}; System.out.println("usermapdao List queryUsers a :"+a[0]+","+a[1]); List tmp1= this.getHibernateTemplate().find(hql,a); System.out.println("usermapdao List queryUsers size:"+tmp1.size()); return tmp1; // return this.getHibernateTemplate().find(hql); }
login.jsp:
<form name="login" action="login.action" method="post">
<input type="text" name="name" id="name" />
<input type="text" name="pass" id="pass" />
<input type="submit" value="submit">
</form>
error as follows:
Hibernate:
select
user0_.ID as ID0_,
user0_.NAME as NAME0_,
user0_.PASS as PASS0_,
user0_.DISCREBTION as DISCREBT4_0_
from
user user0_
where
user0_.NAME=?
and user0_.PASS=?
java.lang.StringIndexOutOfBoundsException: String index out of range: 4
at java.lang.String.charAt(String.java:686)
at com.mysql.jdbc.StringUtils.escapeEasternUnicodeByt eStream(StringUtils.java:231)
at com.mysql.jdbc.StringUtils.getBytesWrapped(StringU tils.java:575)
at com.mysql.jdbc.PreparedStatement.setString(Prepare dStatement.java:4466)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.logicalcobwebs.proxool.ProxyStatement.invoke(P roxyStatement.java:100)
at org.logicalcobwebs.proxool.ProxyStatement.intercep t(ProxyStatement.java:57)
at $java.sql.Wrapper$$EnhancerByProxool$$14ff466.setS tring(<generated>)
at org.hibernate.type.descriptor.sql.VarcharTypeDescr iptor$1.doBind(VarcharTypeDescriptor.java:52)
at org.hibernate.type.descriptor.sql.BasicBinder.bind (BasicBinder.java:91)
at org.hibernate.type.AbstractStandardBasicType.nullS afeSet(AbstractStandardBasicType.java:283)
at org.hibernate.type.AbstractStandardBasicType.nullS afeSet(AbstractStandardBasicType.java:278)
at org.hibernate.param.PositionalParameterSpecificati on.bind(PositionalParameterSpecification.java:68)
at org.hibernate.loader.hql.QueryLoader.bindParameter Values(QueryLoader.java:571)
at org.hibernate.loader.Loader.prepareQueryStatement( Loader.java:1716)
at org.hibernate.loader.Loader.doQuery(Loader.java:80 1)
at org.hibernate.loader.Loader.doQueryAndInitializeNo nLazyCollections(Loader.java:274)
at org.hibernate.loader.Loader.doList(Loader.java:253 3)
at org.hibernate.loader.Loader.listIgnoreQueryCache(L oader.java:2276)
at org.hibernate.loader.Loader.list(Loader.java:2271)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoa der.java:452)
at org.hibernate.hql.ast.QueryTranslatorImpl.list(Que ryTranslatorImpl.java:363)
at org.hibernate.engine.query.HQLQueryPlan.performLis t(HQLQueryPlan.java:196)
at org.hibernate.impl.SessionImpl.list(SessionImpl.ja va:1268)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:1 02)
at org.springframework.orm.hibernate3.HibernateTempla te$30.doInHibernate(HibernateTemplate.java:921)
at org.springframework.orm.hibernate3.HibernateTempla te$30.doInHibernate(HibernateTemplate.java:1)
at org.springframework.orm.hibernate3.HibernateTempla te.doExecute(HibernateTemplate.java:406)
at org.springframework.orm.hibernate3.HibernateTempla te.executeWithNativeSession(HibernateTemplate.java :374)
at org.springframework.orm.hibernate3.HibernateTempla te.find(HibernateTemplate.java:912)
at dao.UserMapDao.queryUsers(UserMapDao.java:60)
at service.UserService.login(UserService.java:44)
at action.LoginAction.execute(LoginAction.java:17)
The weird point is while I'm using the hql like "FROM com.User",without any parameter for "where",it worked well.
Anyone suffered this problem?