-->
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.  [ 4 posts ] 
Author Message
 Post subject: Query By Example + YesNoType = Bug ?
PostPosted: Mon Nov 07, 2005 2:07 am 
Newbie

Joined: Mon Dec 20, 2004 11:53 am
Posts: 8
Hibernate version: 3.0.5

When using Query by example with a class that has a boolean mapped to a yes_no type, Hibernate is binding 'true' or 'false' instead of 'Y' or 'N'. Is this a bug, and are there any workarounds? Inserting and retreiving an item from the db seem to working fine and binding the 'Y' / 'N' correctly, the problem is only when running a Criteria query...


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 07, 2005 8:22 am 
Beginner
Beginner

Joined: Fri Oct 28, 2005 10:46 am
Posts: 37
How about some code? Configuration? Exceptions? Generated SQL? Something that might shed light on the problem?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 07, 2005 9:18 am 
Newbie

Joined: Mon Dec 20, 2004 11:53 am
Posts: 8
Here's the mapping file:

Code:
<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE hibernate-mapping PUBLIC
    "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping>
    <class
        name="com.mmi.intouch.model.Issue"
        table="issue">

        <id
            name="id"
            column="issue_id"
            type="java.lang.Integer"
            unsaved-value="null">
            <generator class="increment" />
        </id>

        <property
            name="escalate"
            type="yes_no"
            update="true"
            insert="true"
            column="escalate"
        />
...


and the Issue class:
Code:
public class Issue extends BaseObject {

private Integer id;
private Boolean escalate = true;
   
    public Boolean getEscalate() {
        return escalate;
    }
    public void setEscalate(Boolean escalate) {
        this.escalate = escalate;
    }
   
    public Integer getId() {
       return id;
    }
    public void setId(Integer id) {
       this.id = id;
    }
...
}


I am creating the query like this:

Code:
Example ex = Example.create(issue).excludeZeroes().ignoreCase().enableLike(MatchMode.ANYWHERE);
Criteria c =  session.createCriteria(Issue.class).add(ex);
return c.list();


Here is the hibernate generated SQL:
Code:
select [...] from issue this_ inner join citizen citizen1_ on this_.citizen_id=citizen1_.citizen_id inner join street_type streettype2_ on citizen1_.loc_street_type_id=streettype2_.street_type_id where (1=1) and this_.escalate=? and (1=1) and (streettype2_.abbreviation=?) and this_.created>? and this_.created<?
[InTouch] DEBUG [main] NullableType.nullSafeSet(59) | binding 'true' to parameter: 1
[InTouch] DEBUG [main] NullableType.nullSafeSet(59) | binding 'RD' to parameter: 2
[InTouch] DEBUG [main] NullableType.nullSafeSet(52) | binding null to parameter: 3
[InTouch] DEBUG [main] NullableType.nullSafeSet(52) | binding null to parameter: 4


Thanks!


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 08, 2005 2:40 am 
Newbie

Joined: Mon Dec 20, 2004 11:53 am
Posts: 8
This is actually not a bug, I found out that the logger is logging the java value, not the actual value being bound by JDBC. Hibernate is doing the right thing. See this post by Gavin:

http://forum.hibernate.org/viewtopic.php?p=1816#1816


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