-->
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.  [ 3 posts ] 
Author Message
 Post subject: Filters and variable number of parameters.
PostPosted: Wed May 11, 2011 10:43 am 
Newbie

Joined: Fri Dec 15, 2006 4:24 am
Posts: 8
Hi all

I have found something strange using filters, I write that to put some light on it.

I need to filter the data that user views by using a criteria that limits the type, something
like do a "select from Cars" using a filter

Code:

hibernate.cfg.xml:

   <filter-def name="CarColor">
      
      <filter-param name="colors" type="string" />
      
   </filter-def>   

somewhere in car.hbm.xml:

<filter condition="COLOR in (:colors)" name="CarColor"/>



It works fine, at the begining, but the problem arises when you first use
that filter with three colors, and afer, in other place of the application, with
six colors, looks that the number of params is shared between querys and
I end with errors like that:

Code:

ERROR - org.hibernate.util.JDBCExceptionReporter - Falta el parámetro IN o OUT en el índice:: 14

INFO - org.hibernate.type.StringType - could not bind value 'XX' to parameter: 14; Índice de columna no válido
WARN - org.hibernate.util.JDBCExceptionReporter - SQL Error: 17003, SQLState: 99999
ERROR - org.hibernate.util.JDBCExceptionReporter - Índice de columna no válido



I solved it using a trick, if the maximun number of colors is 10, then the filter always has 10 params,
the colors i want to filter and some more to fill the 10. It is not smart but works.

So I share it here to common known.


Top
 Profile  
 
 Post subject: Re: Filters and variable number of parameters.
PostPosted: Wed May 11, 2011 1:43 pm 
Expert
Expert

Joined: Wed Mar 03, 2004 6:35 am
Posts: 1240
Location: Lund, Sweden
You don't say which Hibernate version you are using, but the problem seems very similar to this: http://opensource.atlassian.com/project ... e/HHH-4065

This was fixed before Hibernate 3.5 was released.


Top
 Profile  
 
 Post subject: Re: Filters and variable number of parameters.
PostPosted: Thu May 12, 2011 3:12 am 
Newbie

Joined: Fri Dec 15, 2006 4:24 am
Posts: 8
I'm sorry, I tried with some old versions, so I thought that It was not fixed.

The newest I tried is 3.3.2.GA

Code:
      <dependency>
         <groupId>org.hibernate</groupId>
         <artifactId>hibernate-core</artifactId>
         <version>3.3.2.GA</version>
      </dependency>


Thanks, I'm going to try with 3.5 :-D


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