-->
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: boolean value not getting mapped in hibernate+mySQL
PostPosted: Wed May 04, 2016 6:37 am 
Newbie

Joined: Tue Feb 23, 2016 1:04 pm
Posts: 11
http://stackoverflow.com/questions/36994153/boolean-value-not-getting-mapped-properly-in-hibernate-with-mysql

I am trying to map the result of an exists query(which returns TRUE/FALSE) from a mysql DB to a POJO via resultSetTransformer. I would hope the result of this exists query can get mapped to a boolean but it does not & throws below error :

Code:
.hibernate.PropertyAccessException: IllegalArgumentException occurred while calling setter of TestBean.value


The cause of this exception is shown as :

Code:
java.lang.IllegalArgumentException: argument type mismatch


Java Querying Code :

Code:
public class TestHibernate {

    private static SessionFactory sessionFactory = HibernateUtil.getSessionFactory();

    public static void main(String[] args) throws ParseException{

        try{

            Query query = sessionFactory.openSession().createSQLQuery(""+
                    "select " +
                    " exists(select * from A where id = 3) as value"
                    );

            query.setResultTransformer(Transformers.aliasToBean(TestBean.class));
            List<TestBean> beanList = (List<TestBean>) query.list();
        }catch(Exception e){
            System.out.println(e);
        }

    }
}


The Pojo :

Code:
public class TestBean {

    private boolean value;

    public boolean isValue() {
        return value;
    }

    public void setValue(boolean value) {
        this.value = value;
    }

}


Am i missing something or is it a bug with hibernate or mySql JDBC Driver?

Hibernate version : 3.2.6GA Mysql JDBC Driver : mysql-connector-java-5.1.2


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.