-->
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.  [ 7 posts ] 
Author Message
 Post subject: MySQL 5 dialect and hibernate3
PostPosted: Wed Sep 28, 2005 1:00 pm 
Newbie

Joined: Tue Jul 20, 2004 2:35 pm
Posts: 6
MySQL 5 has a candidate release.

http://www.mysql.com/news-and-events/ne ... e_959.html

We tried to upgrade to MySQL5 with the new MySQL JDBC driver for MySQL5.

We are having issues with mapping especially with

Primitive int, double, boolean mapping.

Is hibernate team planning to upgrade the MySQL dialect to incorporate changes for MySQL 5?

Thanks
Gopal


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 28, 2005 3:18 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
you could start by telling about the issues and we could start from there ;)

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 05, 2005 12:43 pm 
Newbie

Joined: Tue Jul 20, 2004 2:35 pm
Posts: 6
Here is the first set of issues.
I think the problem is more with the latest MySQL jdbc driver for MySQL5 database. "mysql-connector-java-3.1.10-bin.jar".

If you install latest MySQL5 DB, and map any primitive and I am testing with boolean, here is what I found out so far.
============================
12:24:41.187 ERROR - Null value was assigned to a property of primitive type setter of
com.asiasystems.test.entity.company.vo.Company.isDemo; nested exception is org.hibernate.PropertyAccessException: Null value
was assigned to a property of primitive type setter of com.asiasystems.test.entity.company.vo.Company.isDemo
org.springframework.orm.hibernate3.HibernateSystemException: Null value was assigned to a property of primitive type set
ter of com.asiasystems.test.entity.company.vo.Company.isDemo; nested exception is org.hibernate.PropertyAccessException: Null
value was assigned to a property of primitive type setter of com.asiasystems.test.entity.company.vo.Company.isDemo
org.hibernate.PropertyAccessException: Null value was assigned to a property of primitive type setter of com.asiasystems.test
.entity.company.vo.Company.isDemo
at org.hibernate.property.BasicPropertyAccessor$BasicSetter.set(BasicPropertyAccessor.java:59)
at org.hibernate.tuple.AbstractTuplizer.setPropertyValues(AbstractTuplizer.java:207)
at org.hibernate.tuple.PojoTuplizer.setPropertyValues(PojoTuplizer.java:171)
at org.hibernate.persister.entity.BasicEntityPersister.setPropertyValues(BasicEntityPersister.java:2923)
at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:113)
at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:494)
at org.hibernate.loader.Loader.doQuery(Loader.java:413)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:208)
at org.hibernate.loader.Loader.doList(Loader.java:1522)
at org.hibernate.loader.Loader.list(Loader.java:1505)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:400)
at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:271)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:791)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:74)
at org.springframework.orm.hibernate3.HibernateTemplate$32.doInHibernate(HibernateTemplate.java:812)
at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:310)
at org.springframework.orm.hibernate3.HibernateTemplate.findByNamedQuery(HibernateTemplate.java:803)
at org.springframework.orm.hibernate3.HibernateTemplate.findByNamedQuery(HibernateTemplate.java:795)
at com.asiasystems.test.entity.company.CompanyDAOImpl.findAllCompanies(CompanyDAOImpl.java:153)


================

Now here is the kicker. Keeping "everything" same, and just changing the JDBC driver to a slightly older version
"mysql-connector-java-3.0-nightly-20050427-bin.jar"

Everything works fine.

==============

So I think the MySQL Dialect needs to be updated. Also this might be due to the fact that MySQL driver probably changed the enums for primitive datatypes and the dialect when look at the enum returned thinks it is not a primitive type anymore and hence this confusion.

Thanks for your help,
Gopal Koratana


Top
 Profile  
 
 Post subject: null values
PostPosted: Wed Oct 05, 2005 2:37 pm 
Beginner
Beginner

Joined: Thu May 05, 2005 4:49 pm
Posts: 30
Hello,

I had the same problem and it's because the DDL statements don't make boolean columns not-null even if you specify that constraint in the hibernate mappings. So to fix the tables, run the following mysql command:

alter table [table] change [column] [column] tinyint(1) not null default 0;

Instead of tinyint(1), mysql 5 uses "bit".


Top
 Profile  
 
 Post subject: clarification
PostPosted: Wed Oct 05, 2005 2:39 pm 
Beginner
Beginner

Joined: Thu May 05, 2005 4:49 pm
Posts: 30
The DDL statements generated by schemaExport DO contain the not-null constraint, but adding a boolean value to the hibernate mapping and running schema update does NOT add the constraint.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 05, 2005 2:55 pm 
Newbie

Joined: Tue Jul 20, 2004 2:35 pm
Posts: 6
Here how my table looks
mysql> desc company;
+--------------------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default
+--------------------+--------------+------+-----+---------+-------+
| OID | varchar(20) | NO | PRI |
| CREATED_BY | varchar(20) | YES | | NULL
| LAST_UPDATED_ON | datetime | NO | |
| LOGO | varchar(100) | YES | | NULL
| IS_DEMO | char(1) | YES | | 0
+--------------------+--------------+------+-----+---------+-------+


Also how do you explain that it works with the previous "nightly build" with the exact same database.

Thanks,
Gopal


Top
 Profile  
 
 Post subject: Interesting observation on this issue
PostPosted: Tue Oct 11, 2005 2:07 pm 
Newbie

Joined: Tue Jul 20, 2004 2:35 pm
Posts: 6
We are able to save the object to DB, it is while reading it back fom DB we get this error.

Thanks,
Gopal


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