Here's the packages I'm using
7-Jul-2007 9:22:16 PM org.hibernate.cfg.annotations.Version <clinit>
INFO: Hibernate Annotations 3.3.0.GA
7-Jul-2007 9:22:16 PM org.hibernate.cfg.Environment <clinit>
INFO: Hibernate 3.2.4.sp1
7-Jul-2007 9:22:16 PM org.hibernate.cfg.Environment <clinit>
INFO: hibernate.properties not found
7-Jul-2007 9:22:16 PM org.hibernate.cfg.Environment buildBytecodeProvider
INFO: Bytecode provider name : cglib
7-Jul-2007 9:22:16 PM org.hibernate.cfg.Environment <clinit>
INFO: using JDK 1.4 java.sql.Timestamp handling
7-Jul-2007 9:22:16 PM org.hibernate.ejb.Version <clinit>
INFO: Hibernate EntityManager 3.3.1.GA
With
7-Jul-2007 9:22:17 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: RDBMS: MySQL, version: 5.0.38-Ubuntu_0ubuntu1-log
7-Jul-2007 9:22:17 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC driver: MySQL-AB JDBC Driver, version: mysql-connector-java-5.0.6 ( $Date: 2007-03-09 22:13:57 +0100 (Fri, 09 Mar 2007) $, $Revision: 6341 $ )
7-Jul-2007 9:22:17 PM org.hibernate.dialect.Dialect <init>
INFO: Using dialect: org.hibernate.dialect.MySQL5Dialect
The table has following structure:
Code:
CREATE TABLE `IN_CATEGORY` (
`CATEGORY_ID` int(11) NOT NULL auto_increment,
`PREFIX` char(2) NOT NULL,
`EXTENSION` char(3) NOT NULL,
`PARENT_ID` int(11) default NULL,
PRIMARY KEY (`CATEGORY_ID`),
UNIQUE KEY `CATEGORY` (`PREFIX`,`EXTENSION`),
KEY `FK_PARENT_ID` (`PARENT_ID`),
CONSTRAINT `FK_PARENT_ID` FOREIGN KEY (`PARENT_ID`) REFERENCES `IN_CATEGORY` (`CATEGORY_ID`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8
I got some problem when executing this query:Code:
Query query = em.createNativeQuery("select PREFIX from IN_CATEGORY where PREFIX='IC'");
Object result = query.getSingleResult();
System.out.println(result + " is of " + result.getClass());
Query output:Code:
Hibernate:
select
PREFIX
from
IN_CATEGORY
where
PREFIX='IC'
I is of class java.lang.Character
How... can this be right? Isn't char length > 1 suppose to be converted to String??