[hibernate-dev] Problem with setting boolean parameter

Oto Júnior otojunior at gmail.com
Mon Dec 17 10:12:03 EST 2012


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