-->
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.  [ 1 post ] 
Author Message
 Post subject: query.setBoolean not working with MySQL 4.0.18
PostPosted: Tue Jun 29, 2004 11:39 pm 
Beginner
Beginner

Joined: Tue Sep 09, 2003 5:20 pm
Posts: 43
I am getting unexpected results from an HQL query using Hibernate 2.1.4 and MySQL 4.0.18.


I have a Status table/object (PoStatus) that has a boolean property
"validForNewUse". It is defined as follows:
Code:
        /**
         * Valid for new use.
         * Returns true if objects of this status may be referenced
         * when creating new objects.
         * @return boolean
         * @hibernate.property
         */
        public boolean isValidForNewUse() {
                return validForNewUse;
        }


My table definition is:
Code:
create table PoStatus (
   id BIGINT NOT NULL AUTO_INCREMENT,
   version INTEGER not null,
   validForNewUse BIT, -- THIS IS THE COLUMN
   name VARCHAR(255),
    ...
   primary key (id),
   unique (name)
) type=InnoDB ;


I am building the query dynamically depending on user selections and role, but here are the HQL and the setBoolean I use:
Code:
  querySB.append("select ch.id, ch.name"+"  from PoChar ch");
  querySB.append(" where ch.charType in (:charType_intrinsic, :charType_single_choice)");
  querySB.append("  and ch.name != :ommitted_name");
  // Only want to see Active characteristics
  querySB.append("  and ch.status.validForNewUse = :validForNewUse "); // HERE IS THE CONDITION USING THE COLUMN
  query =  ses.createQuery(querySB.toString());
  query.setString("charType_intrinsic", PoChar.TYPE_INTRINSIC);
  query.setString("charType_single_choice", PoChar.TYPE_SINGLE_CHOICE);
  query.setString("ommitted_name", PoChar.INTRINSIC_NAME_CLASS);
  // Only want to see Active characteristics
  query.setBoolean("validForNewUse", true);// HERE IS WHERE THE SETBOOLEAN IS
  query.setParameterList("ownerFilterList", ownerFilterList);
   List ql = query.list();


The problem is that when setting the parameters in the MySQL prepared statement, tries to set the column validForNewUse to the character string "true" instead of a 1. I've read and read - until version 4.1 (which is not production ready yet), MySQL does not support the true keyword.

Any suggestions onhow to fix this? I've looked in the Reference guide (no setBoolean examples) and I have searched the forums for prior situations.

My log messages follow. Thanks in advance for any suggestions.

- Richard

Code:
20:06:55,156 DEBUG [http8080-Processor24] QueryTranslator:199 - HQL: select ch.id, ch.name  from com.ltoj.persistence.base.PoChar ch where ch.charType in (:charType_intrinsic, :charType_single_choice)   and ch.name != :ommitted_name  and ch.status.validForNewUse = :validForNewUse   and ch.owner.id in (:ownerFilterList0_, :ownerFilterList1_, :ownerFilterList2_, :ownerFilterList3_, :ownerFilterList4_)  order by ch.name
20:06:55,156 DEBUG [http8080-Processor24] QueryTranslator:200 - SQL: select pochar0_.id as x0_0_, pochar0_.name as x1_0_ from PoChar pochar0_, PoStatus postatus1_ where (pochar0_.charType in(? , ?))and(pochar0_.name!=? )and(postatus1_.validForNewUse=?  and pochar0_.status=postatus1_.id)and(pochar0_.owner in(? , ? , ? , ? , ?)) order by  pochar0_.name
20:06:55,156 DEBUG [http8080-Processor24] BatcherImpl:196 - about to open: 0 open PreparedStatements, 0 open ResultSets
20:06:55,171 DEBUG [http8080-Processor24] SQL:237 - select pochar0_.id as x0_0_, pochar0_.name as x1_0_ from PoChar pochar0_, PoStatus postatus1_ where (pochar0_.charType in(? , ?))and(pochar0_.name!=? )and(postatus1_.validForNewUse=?  and pochar0_.status=postatus1_.id)and(pochar0_.owner in(? , ? , ? , ? , ?)) order by  pochar0_.name
20:06:55,171 DEBUG [http8080-Processor24] BatcherImpl:241 - preparing statement
20:06:55,171 DEBUG [http8080-Processor24] LongType:46 - binding '31053' to parameter: 6
20:06:55,171 DEBUG [http8080-Processor24] BooleanType:46 - binding 'true' to parameter: 4
20:06:55,171 DEBUG [http8080-Processor24] LongType:46 - binding '31054' to parameter: 9
20:06:55,171 DEBUG [http8080-Processor24] LongType:46 - binding '31053' to parameter: 8
20:06:55,171 DEBUG [http8080-Processor24] LongType:46 - binding '31055' to parameter: 5
20:06:55,171 DEBUG [http8080-Processor24] LongType:46 - binding '2' to parameter: 7
20:06:55,171 DEBUG [http8080-Processor24] StringType:46 - binding 'I' to parameter: 1
20:06:55,171 DEBUG [http8080-Processor24] StringType:46 - binding 'C' to parameter: 2
20:06:55,171 DEBUG [http8080-Processor24] StringType:46 - binding 'Class' to parameter: 3
20:06:55,218 DEBUG [http8080-Processor24] Loader:197 - processing result set
20:06:55,218 DEBUG [http8080-Processor24] Loader:226 - done processing result set (0 rows)
20:06:55,218 DEBUG [http8080-Processor24] BatcherImpl:203 - done closing: 0 open PreparedStatements, 0 open ResultSets
20:06:55,218 DEBUG [http8080-Processor24] BatcherImpl:261 - closing statement


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.