-->
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.  [ 4 posts ] 
Author Message
 Post subject: Trouble using query.setProperties() with list parameters?
PostPosted: Wed Aug 27, 2003 1:09 pm 
Beginner
Beginner

Joined: Tue Aug 26, 2003 4:19 pm
Posts: 42
I'm having trouble using query.setProperties() to set List parameters. As I'm stepping through my code, I can see that Hibernate correctly sees the named parameter, calls the getBlabla method on my bean, the bean returns a good value (an arraylist of Integers in this case), but when Hibernate executes the query, PostgreSQL returns this parse error:

pg_atoi: error in "\254\355\000\005ur\000\024[Ljava.lang.Integer;\376\227\255\240\001\203\342\033\002\000\000xp\000\000\000\001sr\000\021java.lang.Integer\022\342\240\244\367\201\2078\002\000\001I\000\005valuexr\000\020java.lang.Number\206\254\225\035\013\224\340\213\002\000\000xp\000\000:\312": can't parse "\254\355\000\005ur\000\024[Ljava.lang.Integer;\376\227\255\240\001\203\342\033\002\000\000xp\000\000\000\001sr\000\021java.lang.Integer\022\342\240\244\367\201\2078\002\000\001I\000\005valuexr\000\020java.lang.Number\206\254\225\035\013\224\340\213\002\000\000xp\000\000:\312"

Also, when I step through up to query.list(), and inspect the namedParameterLists hashmap, the map is empty. Normal parameters are visible in the map, set properly and work fine, BTW. And when I name the parameterLists manually, it works fine, but not with setProperties().


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 27, 2003 2:13 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
namedParameterLists does *not* hold named parameters set using setProperties()! Only parameters set using setParameterList().

Well, this is really nowhere near enough information to help any further.


Top
 Profile  
 
 Post subject: More details
PostPosted: Wed Aug 27, 2003 4:53 pm 
Beginner
Beginner

Joined: Tue Aug 26, 2003 4:19 pm
Posts: 42
Ok, here's some more details. Any hints would be much appreciated.

The complete stack trace is at the bottom.

here's the HQL:
select myresult from Result myresult where (myresult.user.age >= (:minage) and myresult.user.age <= (:maxage)) and myresult.team.id in (:teamids) order by myresult.race.event.eventdate desc

and here's the SQL:
Hibernate: select result0_.resultid as resultid, result0_.place as place, result0_.time as time, result0_.categoryid as categoryid, result0_.raceid as raceid, result0_.teamid as teamid, result0_.userid as userid from result result0_, users user1_, race race2_, event event3_ where result0_.raceid=race2_.raceid and race2_.eventid=event3_.eventid and (((user1_.age>=(?) and result0_.userid=user1_.userid)and(user1_.age<=(?) and result0_.userid=user1_.userid))and(result0_.teamid in(?))) order by event3_.eventdate desc limit ?, ?

I noticed is that the generated SQL is different if I set the List parameters with setParameterList versus using setProperties(). With setProperties(), the generated SQL for the List parameter when supplying an ArrayList of three integers is:
result0_.teamid in(?)

But when I use setParameterList(), I get:
result0_.teamid in(? , ? , ?)

guessType isn't throwing an exception, so Hibernate must recognize the list of integers, but I only see one (?) in the query string, and when the query executes, I get this:

java.sql.SQLException: ERROR: pg_atoi: error in "\254\355\000\005ur\000\024[Ljava.lang.Integer;\376\227\255\240\001\203\342\033\002\000\000xp\000\000\000\002psr\000\021java.lang.Integer\022\342\240\244\367\201\2078\002\000\001I\000\005valuexr\000\020java.lang.Number\206\254\225\035\013\224\340\213\002\000\000xp\000\000 \300": can't parse "\254\355\000\005ur\000\024[Ljava.lang.Integer;\376\227\255\240\001\203\342\033\002\000\000xp\000\000\000\002psr\000\021java.lang.Integer\022\342\240\244\367\201\2078\002\000\001I\000\005valuexr\000\020java.lang.Number\206\254\225\035\013\224\340\213\002\000\000xp\000\000 \300"
at org.postgresql.core.QueryExecutor.execute(QueryExecutor.java:131)
at org.postgresql.jdbc1.AbstractJdbc1Connection.ExecSQL(AbstractJdbc1Connection.java:505)
at org.postgresql.jdbc1.AbstractJdbc1Statement.execute(AbstractJdbc1Statement.java:320)
at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:48)
at org.postgresql.jdbc1.AbstractJdbc1Statement.executeQuery(AbstractJdbc1Statement.java:153)
at net.sf.hibernate.impl.BatcherImpl.getResultSet(BatcherImpl.java:62)
at net.sf.hibernate.loader.Loader.getResultSet(Loader.java:537)
at net.sf.hibernate.loader.Loader.doFind(Loader.java:140)
at net.sf.hibernate.loader.Loader.find(Loader.java:604)
at net.sf.hibernate.hql.QueryTranslator.find(QueryTranslator.java:912)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1356)
at net.sf.hibernate.impl.QueryImpl.list(QueryImpl.java:76)
at com.services.ViewResultsService$ViewResults.viewResults(ViewResultsService.java:95)
at com.action.ViewResultsAction.viewresults(ViewResultsAction.java:58)
at sun.reflect.GeneratedMethodAccessor266.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 27, 2003 4:59 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
setProperties() cannot be used to implement the functionality of setParameterList(). This probably explains the problem.


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