-->
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.  [ 5 posts ] 
Author Message
 Post subject: Assistance needed with criteria
PostPosted: Tue Mar 14, 2006 10:12 am 
Newbie

Joined: Fri Sep 23, 2005 9:48 am
Posts: 4
Hi!

This is my first post and I need some assistance. I could not find an answer searching or reading the documentation. (I am still "new" to hibernate, so please bear with me.)

I am using criteria to return limited results. I have no problems with criteria using fields that are varchar2, integer, or an instance of another class. My problem lies with trying to use criteria with a boolean field.

In my hbm.xml file, I have the field declared as such:
<property name="accredTeam" type="boolean" not-null="true">

In java, I get/set the field of:
private boolean accredTeam;

I have no problems, getting or setting this field. I just cannot create criteria with it.

This is what I last tried:
criteria.add(Restrictions.eq("accredTeam", new Boolean(true)));

Hibernate version: 3.0
Name and version of the database you are using: Oracle 9i

I would appreciate any help.
Thanks,
Lori


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 14, 2006 11:57 am 
Senior
Senior

Joined: Mon Aug 22, 2005 5:45 am
Posts: 146
try using Object, not primitive type:

<property name="accredTeam" type="java.lang.Boolean" not-null="true">

any exception being thrown or what is the behaviour?

_________________
Please don't forget to give credit, if my posting helped to solve your problem.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 16, 2006 11:33 am 
Newbie

Joined: Fri Sep 23, 2005 9:48 am
Posts: 4
Thanks for the idea, but it did not work. Any other ideas?

I am not getting an error. I am just not getting the expected results, since the criteria listed above is returning all the records, not just the ones with "accredTeam" = true.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 16, 2006 12:23 pm 
Regular
Regular

Joined: Tue Mar 07, 2006 11:18 am
Posts: 54
Location: Berlin
Hi,
could you please post the create-statement you have used to create your table.
did you use a numerical field for "accredTeam"?

simon


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 17, 2006 2:12 pm 
Newbie

Joined: Fri Sep 23, 2005 9:48 am
Posts: 4
When I export the hibernate schema, the field is a number. In the code it is referenced as a boolean. Here is the create for the relevant table:

create table jam.cars_roles (
id number(19,0) not null,
usr_id number(19,0) not null,
name varchar2(255) not null,
appliesTo varchar2(255) not null,
changed date not null,
accredTeam number(1,0) not null,
primary key (id)
);

This is my revised hibernate mapping property:
<property name="accredTeam" type="java.lang.Boolean" not-null="true">


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