[hibernate-dev] Problem with setting boolean parameter

Steve Ebersole steve at hibernate.org
Mon Dec 17 10:22:16 EST 2012


No, that is no longer possible.  You have a boolean, you should set a 
boolean.

On 12/17/2012 09:12 AM, Oto Júnior wrote:
> Correct.
>
> In Hibernate 2, this example with 'q.setParameter(  "isActive", 1 );' works !
> In Hibernate 4 doesn't work.
>
> Is there any way to make work in Hibernate 4 without modify the
> implementation of my method?
> (i.e. I want to use 'q.setParameter(  "isActive", 1 );' )
>
> Observation: In the database the 'true' values are stored with number
> 1 and 'false' values are stored with number 0.
>
>
> _______________________________________________________
> Oto Soares Coelho Júnior
> otojunior at gmail.com / otojr at dcc.ufmg.br
> Departamento de Ciência da Computação - UFMG
>
>
> 2012/12/17 Steve Ebersole <steve at hibernate.org>:
>> Just to make sure I understand...
>>
>> You have a domain attribute that is boolean, but you want to treat it as a
>> number?
>>
>> I.e.:
>> @Entity class Listing {
>>     ...
>>     boolean active;
>> }
>>
>> Query q = session.createQuery( "from Listing l where listing.active =
>> :isActive" );
>> q.setParameter(  "isActive", 1 );
>>
>> rather than:
>> q.setParameter(  "isActive", true );
>>
>> ?
>>
>> On 12/17/2012 07:34 AM, Oto Júnior wrote:
>>> Hi,
>>>
>>> I used Hibernate 2 in my software and now I'm using Hibernate 4.
>>> Before the version migration, the method Query.setParameter(p, 1) -
>>> [Integer values in boolean properties] - works well for setting
>>> boolean properties.
>>>
>>> Now, in Hibernate 4, doesn't work anymore.
>>> Anyone could help me?
>>>
>>>
>>> _______________________________________________________
>>> Oto Soares Coelho Júnior
>>> otojunior at gmail.com / otojr at dcc.ufmg.br
>>> Departamento de Ciência da Computação - UFMG
>>>
>>> _______________________________________________
>>> hibernate-dev mailing list
>>> hibernate-dev at lists.jboss.org
>>> https://lists.jboss.org/mailman/listinfo/hibernate-dev
>>



More information about the hibernate-dev mailing list