[hibernate-dev] Problem with setting boolean parameter

Oto Júnior otojunior at gmail.com
Mon Dec 17 11:01:17 EST 2012


Yes Eric, this is a project/implementation detail.

I wrote here just for a "extra-information" of my problem. But you're right.

Thanks.

_______________________________________________________
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 Eric Dalquist <eric.dalquist at doit.wisc.edu>:
> Also isn't the 1/0 for boolean storage a DB specific implementation
> detail? For example if running hibernate against HSQLDB you get true
> boolean columns.
>
> -Eric
>
>
> On 12/17/2012 09:22 AM, Steve Ebersole wrote:
>> 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
>> _______________________________________________
>> 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