Results 1 to 2 of 2
  1. #1
    colmen is offline Member
    Join Date
    Oct 2012
    Posts
    1
    Rep Power
    0

    Default Wired problem from hibernate.

    It's new to hibernate,using SSH framework,database is mysql 5,
    I've got weird problem here.
    attach DAO code:
    UserMapDao.java(part):
    @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);
    }
    attached the website login.jsp, & got an error:
    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:
    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?
    Last edited by colmen; 10-13-2012 at 08:42 AM. Reason: spelling errors

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,236
    Rep Power
    19

    Default Re: Wired problem from hibernate.

    Moved from Advanced Java.

    Cross posted
    weird problem in hibernate | Java.net

    Any more?

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. Problem with hibernate insert
    By dennisbf in forum New To Java
    Replies: 11
    Last Post: 09-15-2011, 06:25 PM
  2. Hibernate config problem
    By tam in forum JDBC
    Replies: 0
    Last Post: 01-31-2011, 10:28 PM
  3. problem in hibernate
    By jperson in forum JDBC
    Replies: 1
    Last Post: 01-11-2011, 10:10 AM
  4. Hibernate aplication Problem
    By Prashant.surwade in forum Advanced Java
    Replies: 6
    Last Post: 09-18-2009, 10:32 AM
  5. problem in hibernate need help!
    By jrgahan in forum Advanced Java
    Replies: 0
    Last Post: 05-22-2008, 09:00 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •