-->
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.  [ 10 posts ] 
Author Message
 Post subject: Wrong column type: EMPNO, expected: varchar(255)
PostPosted: Fri Mar 03, 2006 2:25 pm 
Newbie

Joined: Fri Mar 03, 2006 2:11 pm
Posts: 16
Hibernate version: 3.1.2

Mapping documents:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN" "C:/sf/hibernate/hibernatesample/WebContent/WEB-INF/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<class name="com.sf.hibernate.Employee" table="EMPLOYEE">

<id name="empNo" type="string" column="EMPNO">
<generator class="seqhilo">
<param name="sequence">empseq</param>
<param name="max_lo">100</param>
</generator>
</id>
<!-- A cat has to have a name, but it shouldn' be too long. -->
<property name="firstNme">
<column name="FIRSTNME" />
</property>
<property name="lastName">
<column name="LASTNAME" />
</property>

</class>
</hibernate-mapping>
****************Hibernate config**************
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN" "C:/sf/hibernate/hibernatesample/WebContent/WEB-INF/hibernate-configuration-2.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.driver_class">COM.ibm.db2.jdbc.app.DB2Driver</property>
<property name="hibernate.connection.url">jdbc:db2:SAMPLE</property>
<property name="hibernate.connection.username">svpa</property>
<property name="hibernate.connection.password">password</property>
<property name="hibernate.connection.pool_size">10</property>
<property name="show_sql">true</property>
<property name="dialect">org.hibernate.dialect.DB2Dialect</property>
<property name="hibernate.hbm2ddl.auto">validate</property>
<!-- Mapping files -->
<mapping resource="employee.hbm.xml"/>
</session-factory>
</hibernate-configuration>

Code between sessionFactory.openSession() and session.close():
SessionFactory sf = new Configuration().configure().buildSessionFactory();
Session s = sf.openSession();
List list = s.createSQLQuery("SELECT firstName, lastName empNO from EMPOYEE").addEntity(Employee.class).list();
System.out.println("Test");
Full stack trace of any exception that occurs:
0 [main] INFO org.hibernate.cfg.Environment - Hibernate 3.1.2
10 [main] INFO org.hibernate.cfg.Environment - hibernate.properties not found
10 [main] INFO org.hibernate.cfg.Environment - using CGLIB reflection optimizer
10 [main] INFO org.hibernate.cfg.Environment - using JDK 1.4 java.sql.Timestamp handling
130 [main] INFO org.hibernate.cfg.Configuration - configuring from resource: /hibernate.cfg.xml
130 [main] INFO org.hibernate.cfg.Configuration - Configuration resource: /hibernate.cfg.xml
331 [main] DEBUG org.hibernate.cfg.Configuration - hibernate.connection.driver_class=COM.ibm.db2.jdbc.app.DB2Driver
331 [main] DEBUG org.hibernate.cfg.Configuration - hibernate.connection.url=jdbc:db2:SAMPLE
331 [main] DEBUG org.hibernate.cfg.Configuration - hibernate.connection.username=svpa
331 [main] DEBUG org.hibernate.cfg.Configuration - hibernate.connection.password=ANil85in
331 [main] DEBUG org.hibernate.cfg.Configuration - hibernate.connection.pool_size=10
331 [main] DEBUG org.hibernate.cfg.Configuration - show_sql=true
331 [main] DEBUG org.hibernate.cfg.Configuration - dialect=org.hibernate.dialect.DB2Dialect
331 [main] DEBUG org.hibernate.cfg.Configuration - hibernate.hbm2ddl.auto=validate
331 [main] DEBUG org.hibernate.cfg.Configuration - null<-org.dom4j.tree.DefaultAttribute@2c78538 [Attribute: name resource value "employee.hbm.xml"]
331 [main] INFO org.hibernate.cfg.Configuration - Reading mappings from resource: employee.hbm.xml
601 [main] INFO org.hibernate.cfg.HbmBinder - Mapping class: com.sf.hibernate.Employee -> EMPLOYEE
611 [main] DEBUG org.hibernate.cfg.HbmBinder - Mapped property: empNo -> EMPNO
641 [main] DEBUG org.hibernate.cfg.HbmBinder - Mapped property: firstNme -> FIRSTNME
641 [main] DEBUG org.hibernate.cfg.HbmBinder - Mapped property: lastName -> LASTNAME
641 [main] INFO org.hibernate.cfg.Configuration - Configured SessionFactory: null
641 [main] DEBUG org.hibernate.cfg.Configuration - properties: {java.assistive=ON, hibernate.connection.password=ANil85in, java.runtime.name=Java(TM) 2 Runtime Environment, Standard Edition, sun.boot.library.path=C:\Program Files\IBM\WebSphere Studio\Application Developer\v5.1.2\runtimes\base_v51\java\jre\bin, java.vm.version=1.4.1, hibernate.connection.username=svpa, java.vm.vendor=IBM Corporation, java.vendor.url=http://www.ibm.com/, path.separator=;, java.vm.name=Classic VM, file.encoding.pkg=sun.io, user.country=US, sun.os.patch.level=Service Pack 2, java.vm.specification.name=Java Virtual Machine Specification, user.dir=C:\sf\hibernate3\TestHibernateWeb, java.runtime.version=1.4.1, java.fullversion=J2RE 1.4.1 IBM Windows 32 build cn1411-20031011 (JIT enabled: jitc), java.awt.graphicsenv=sun.awt.Win32GraphicsEnvironment, java.endorsed.dirs=C:\Program Files\IBM\WebSphere Studio\Application Developer\v5.1.2\runtimes\base_v51\java\jre\lib\endorsed, os.arch=x86, java.io.tmpdir=C:\TEMP\, line.separator=
, java.vm.specification.vendor=Sun Microsystems Inc., user.variant=, java.awt.fonts=, os.name=Windows XP, sun.java2d.fontpath=, java.library.path=C:\Program Files\IBM\WebSphere Studio\Application Developer\v5.1.2\runtimes\base_v51\java\bin;.;C:\WINNT\system32;C:\WINNT;C:\Program Files\IBM\WebSphere Studio\Application Developer\v5.1.2\eclipse\jre\bin;C:\PROGRA~1\ORA920\bin;C:\PROGRA~1\ORA920\jre\1.4.2\bin\client;C:\PROGRA~1\ORA920\jre\1.4.2\bin;C:\Program Files\Oracle\jre\1.3.1\bin;C:\Program Files\Oracle\jre\1.1.8\bin;C:\PROGRAM FILES\THINKPAD\UTILITIES;C:\WINNT\system32;C:\WINNT;C:\Progra~1\Serena\CHANGE~1\DIMENS~1\9.1\PROG;c:\progra~1\Merant\DIMENS~1\8.0\PROG;C:\Program Files\Host Integration Server\system;C:\WINNT\System32\Wbem;%PRODDIR%\ISS;C:\PROD\ISS;C:\PROGRAM FILES\RUMBA\SYSTEM;C:\PROGRA~1\DB2\SQLLIB\BIN;C:\PROGRA~1\DB2\SQLLIB\FUNCTION;C:\DOCUMENTS AND SETTINGS\ALL USERS\APPLICATION DATA\NOTES;C:\PROGRAM FILES\NOTES;C:\PROGRA~1\DB2\SQLLIB\SAMPLES\REPL;C:\Program Files\VSEW310;C:\Program Files\VSEW310\Lib;C:\Program Files\VSEW310\qelib;C:\PROD\WSD\SMSNomad\;C:\Program Files\FileNET\IDM;C:\Program Files\Rumba\;C:\Program Files\Protocom\SecureLogin\;gram Files\Protocom\SecureLogin;C:\PROD\WSD\SMSNomad;C:\Program Files\HEWLETT-PACKARD\CLIENT\bin;C:\Program Files\InstallShield\AdminStudio\6.0\ConflictSolver;%PATH%;C:\Program Files\VS60\Common\Tools\WinNT;C:\Program Files\VS60\Common\MSDev98\Bin;C:\Program Files\VS60\Common\Tools;C:\Program Files\VS60\VC98\bin;C:\PROGRA~1\NETMAN~1\NETMAN~1\COMMON, java.specification.name=Java Platform API Specification, java.class.version=48.0, hibernate.connection.pool_size=10, ibm.system.encoding=Cp1252, java.util.prefs.PreferencesFactory=java.util.prefs.WindowsPreferencesFactory, invokedviajava=, os.version=5.1, user.home=C:\Documents and Settings\svpa, user.timezone=, java.awt.printerjob=sun.awt.windows.WPrinterJob, file.encoding=Cp1252, java.specification.version=1.4, hibernate.connection.driver_class=COM.ibm.db2.jdbc.app.DB2Driver, show_sql=true, java.class.path=C:\sf\hibernate3\TestHibernateWeb\WebContent\WEB-INF\classes;C:\Program Files\IBM\WebSphere Studio\Application Developer\v5.1.2\runtimes\base_v5\java\jre\lib\rt.jar;C:\Program Files\IBM\WebSphere Studio\Application Developer\v5.1.2\runtimes\base_v5\lib\j2ee.jar;C:\Program Files\IBM\WebSphere Studio\Application Developer\v5.1.2\runtimes\base_v5\lib\servletevent.jar;C:\Program Files\IBM\WebSphere Studio\Application Developer\v5.1.2\runtimes\base_v5\lib\ivjejb35.jar;C:\Program Files\IBM\WebSphere Studio\Application Developer\v5.1.2\runtimes\base_v5\lib\runtime.jar;C:\Documents and Settings\svpa\Desktop\harinder\hibernate3\hibernate312\hibernate-3.1\lib\ant-1.6.5.jar;C:\Documents and Settings\svpa\Desktop\harinder\hibernate3\hibernate312\hibernate-3.1\lib\ant-antlr-1.6.5.jar;C:\Documents and Settings\svpa\Desktop\harinder\hibernate3\hibernate312\hibernate-3.1\lib\ant-junit-1.6.5.jar;C:\Documents and Settings\svpa\Desktop\harinder\hibernate3\hibernate312\hibernate-3.1\lib\ant-launcher-1.6.5.jar;C:\Documents and Settings\svpa\Desktop\harinder\hibernate3\hibernate312\hibernate-3.1\lib\antlr-2.7.6rc1.jar;C:\Documents and Settings\svpa\Desktop\harinder\hibernate3\hibernate312\hibernate-3.1\lib\ant-swing-1.6.5.jar;C:\Documents and Settings\svpa\Desktop\harinder\hibernate3\hibernate312\hibernate-3.1\lib\asm.jar;C:\Documents and Settings\svpa\Desktop\harinder\hibernate3\hibernate312\hibernate-3.1\lib\asm-attrs.jar;C:\Documents and Settings\svpa\Desktop\harinder\hibernate3\hibernate312\hibernate-3.1\lib\c3p0-0.9.0.jar;C:\Documents and Settings\svpa\Desktop\harinder\hibernate3\hibernate312\hibernate-3.1\lib\cglib-2.1.3.jar;C:\Documents and Settings\svpa\Desktop\harinder\hibernate3\hibernate312\hibernate-3.1\lib\cleanimports.jar;C:\Documents and Settings\svpa\Desktop\harinder\hibernate3\hibernate312\hibernate-3.1\lib\commons-collections-2.1.1.jar;C:\Documents and Settings\svpa\Desktop\harinder\hibernate3\hibernate312\hibernate-3.1\lib\commons-logging-1.0.4.jar;C:\Documents and Settings\svpa\Desktop\harinder\hibernate3\hibernate312\hibernate-3.1\lib\concurrent-1.3.2.jar;C:\Documents and Settings\svpa\Desktop\harinder\hibernate3\hibernate312\hibernate-3.1\lib\connector.jar;C:\Documents and Settings\svpa\Desktop\harinder\hibernate3\hibernate312\hibernate-3.1\lib\dom4j-1.6.1.jar;C:\Documents and Settings\svpa\Desktop\harinder\hibernate3\hibernate312\hibernate-3.1\lib\ehcache-1.1.jar;C:\Documents and Settings\svpa\Desktop\harinder\hibernate3\hibernate312\hibernate-3.1\lib\jaas.jar;C:\Documents and Settings\svpa\Desktop\harinder\hibernate3\hibernate312\hibernate-3.1\lib\jacc-1_0-fr.jar;C:\Documents and Settings\svpa\Desktop\harinder\hibernate3\hibernate312\hibernate-3.1\lib\jaxen-1.1-beta-7.jar;C:\Documents and Settings\svpa\Desktop\harinder\hibernate3\hibernate312\hibernate-3.1\lib\jboss-cache.jar;C:\Documents and Settings\svpa\Desktop\harinder\hibernate3\hibernate312\hibernate-3.1\lib\jboss-common.jar;C:\Documents and Settings\svpa\Desktop\harinder\hibernate3\hibernate312\hibernate-3.1\lib\jboss-jmx.jar;C:\Documents and Settings\svpa\Desktop\harinder\hibernate3\hibernate312\hibernate-3.1\lib\jboss-system.jar;C:\Documents and Settings\svpa\Desktop\harinder\hibernate3\hibernate312\hibernate-3.1\lib\jdbc2_0-stdext.jar;C:\Documents and Settings\svpa\Desktop\harinder\hibernate3\hibernate312\hibernate-3.1\lib\jgroups-2.2.8.jar;C:\Documents and Settings\svpa\Desktop\harinder\hibernate3\hibernate312\hibernate-3.1\lib\jta.jar;C:\Documents and Settings\svpa\Desktop\harinder\hibernate3\hibernate312\hibernate-3.1\lib\junit-3.8.1.jar;C:\Documents and Settings\svpa\Desktop\harinder\hibernate3\hibernate312\hibernate-3.1\lib\log4j-1.2.11.jar;C:\Documents and Settings\svpa\Desktop\harinder\hibernate3\hibernate312\hibernate-3.1\lib\oscache-2.1.jar;C:\Documents and Settings\svpa\Desktop\harinder\hibernate3\hibernate312\hibernate-3.1\lib\proxool-0.8.3.jar;C:\Documents and Settings\svpa\Desktop\harinder\hibernate3\hibernate312\hibernate-3.1\lib\swarmcache-1.0rc2.jar;C:\Documents and Settings\svpa\Desktop\harinder\hibernate3\hibernate312\hibernate-3.1\lib\syndiag2.jar;C:\Documents and Settings\svpa\Desktop\harinder\hibernate3\hibernate312\hibernate-3.1\lib\versioncheck.jar;C:\Documents and Settings\svpa\Desktop\harinder\hibernate3\hibernate312\hibernate-3.1\lib\xerces-2.6.2.jar;C:\Documents and Settings\svpa\Desktop\harinder\hibernate3\hibernate312\hibernate-3.1\lib\xml-apis.jar;C:\Program Files\DB2\SQLLIB\java\db2java.zip;C:\Program Files\DB2\SQLLIB\java\db2jcc.jar;C:\Program Files\DB2\SQLLIB\java\db2jcc_license_cu.jar;C:\Documents and Settings\svpa\Desktop\harinder\hibernate3\hibernate312\hibernate-3.1\hibernate3.jar, user.name=svpa, hibernate.show_sql=true, java.vm.specification.version=1.0, java.home=C:\Program Files\IBM\WebSphere Studio\Application Developer\v5.1.2\runtimes\base_v51\java\jre, sun.arch.data.model=32, hibernate.dialect=org.hibernate.dialect.DB2Dialect, hibernate.connection.url=jdbc:db2:SAMPLE, user.language=en, java.specification.vendor=Sun Microsystems Inc., awt.toolkit=sun.awt.windows.WToolkit, hibernate.cglib.use_reflection_optimizer=true, java.vm.info=J2RE 1.4.1 IBM Windows 32 build cn1411-20031011 (JIT enabled: jitc), java.version=1.4.1, java.ext.dirs=C:\Program Files\IBM\WebSphere Studio\Application Developer\v5.1.2\runtimes\base_v51\java\jre\lib\ext, sun.boot.class.path=C:\Program Files\IBM\WebSphere Studio\Application Developer\v5.1.2\runtimes\base_v51\java\jre\lib\core.jar;C:\Program Files\IBM\WebSphere Studio\Application Developer\v5.1.2\runtimes\base_v51\java\jre\lib\graphics.jar;C:\Program Files\IBM\WebSphere Studio\Application Developer\v5.1.2\runtimes\base_v51\java\jre\lib\security.jar;C:\Program Files\IBM\WebSphere Studio\Application Developer\v5.1.2\runtimes\base_v51\java\jre\lib\server.jar;C:\Program Files\IBM\WebSphere Studio\Application Developer\v5.1.2\runtimes\base_v51\java\jre\lib\xml.jar;C:\Program Files\IBM\WebSphere Studio\Application Developer\v5.1.2\runtimes\base_v51\java\jre\lib\charsets.jar, java.vendor=IBM Corporation, file.separator=\, hibernate.hbm2ddl.auto=validate, java.vendor.url.bug=, java.compiler=jitc, sun.io.unicode.encoding=UnicodeLittle, dialect=org.hibernate.dialect.DB2Dialect}
841 [main] DEBUG org.hibernate.cfg.Configuration - Preparing to build session factory with filters : {}
841 [main] DEBUG org.hibernate.cfg.Configuration - processing extends queue
841 [main] DEBUG org.hibernate.cfg.Configuration - processing collection mappings
841 [main] DEBUG org.hibernate.cfg.Configuration - processing native query and ResultSetMapping mappings
841 [main] DEBUG org.hibernate.cfg.Configuration - processing association property references
841 [main] DEBUG org.hibernate.cfg.Configuration - processing foreign key constraints
992 [main] INFO org.hibernate.connection.DriverManagerConnectionProvider - Using Hibernate built-in connection pool (not for production use!)
992 [main] INFO org.hibernate.connection.DriverManagerConnectionProvider - Hibernate connection pool size: 10
992 [main] INFO org.hibernate.connection.DriverManagerConnectionProvider - autocommit mode: false
1112 [main] INFO org.hibernate.connection.DriverManagerConnectionProvider - using driver: COM.ibm.db2.jdbc.app.DB2Driver at URL: jdbc:db2:SAMPLE
1112 [main] INFO org.hibernate.connection.DriverManagerConnectionProvider - connection properties: {user=svpa, password=ANil85in}
1112 [main] DEBUG org.hibernate.connection.DriverManagerConnectionProvider - total checked-out connections: 0
1112 [main] DEBUG org.hibernate.connection.DriverManagerConnectionProvider - opening new JDBC connection
1563 [main] DEBUG org.hibernate.connection.DriverManagerConnectionProvider - created connection to: jdbc:db2:SAMPLE, Isolation Level: 2
1573 [main] DEBUG org.hibernate.cfg.SettingsFactory - could not get database version from JDBC metadata
1573 [main] INFO org.hibernate.cfg.SettingsFactory - RDBMS: DB2/NT, version: 08.01.0003
1573 [main] INFO org.hibernate.cfg.SettingsFactory - JDBC driver: IBM DB2 JDBC 2.0 Type 2, version: 08.01.0003
1573 [main] DEBUG org.hibernate.connection.DriverManagerConnectionProvider - returning connection to pool, pool size: 1
1603 [main] INFO org.hibernate.dialect.Dialect - Using dialect: org.hibernate.dialect.DB2Dialect
1623 [main] INFO org.hibernate.transaction.TransactionFactoryFactory - Using default transaction strategy (direct JDBC transactions)
1623 [main] INFO org.hibernate.transaction.TransactionManagerLookupFactory - No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
1623 [main] INFO org.hibernate.cfg.SettingsFactory - Automatic flush during beforeCompletion(): disabled
1623 [main] INFO org.hibernate.cfg.SettingsFactory - Automatic session close at end of transaction: disabled
1623 [main] INFO org.hibernate.cfg.SettingsFactory - Scrollable result sets: enabled
1623 [main] DEBUG org.hibernate.cfg.SettingsFactory - Wrap result sets: disabled
1623 [main] INFO org.hibernate.cfg.SettingsFactory - JDBC3 getGeneratedKeys(): disabled
1623 [main] INFO org.hibernate.cfg.SettingsFactory - Connection release mode: auto
1623 [main] INFO org.hibernate.cfg.SettingsFactory - Default batch fetch size: 1
1623 [main] INFO org.hibernate.cfg.SettingsFactory - Generate SQL with comments: disabled
1623 [main] INFO org.hibernate.cfg.SettingsFactory - Order SQL updates by primary key: disabled
1623 [main] INFO org.hibernate.cfg.SettingsFactory - Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
1633 [main] INFO org.hibernate.hql.ast.ASTQueryTranslatorFactory - Using ASTQueryTranslatorFactory
1633 [main] INFO org.hibernate.cfg.SettingsFactory - Query language substitutions: {}
1633 [main] INFO org.hibernate.cfg.SettingsFactory - Second-level cache: enabled
1633 [main] INFO org.hibernate.cfg.SettingsFactory - Query cache: disabled
1633 [main] INFO org.hibernate.cfg.SettingsFactory - Cache provider: org.hibernate.cache.EhCacheProvider
1633 [main] INFO org.hibernate.cfg.SettingsFactory - Optimize cache for minimal puts: disabled
1633 [main] INFO org.hibernate.cfg.SettingsFactory - Structured second-level cache entries: disabled
1633 [main] DEBUG org.hibernate.exception.SQLExceptionConverterFactory - Using dialect defined converter
1643 [main] INFO org.hibernate.cfg.SettingsFactory - Echoing all SQL to stdout
1643 [main] INFO org.hibernate.cfg.SettingsFactory - Statistics: disabled
1643 [main] INFO org.hibernate.cfg.SettingsFactory - Deleted entity synthetic identifier rollback: disabled
1643 [main] INFO org.hibernate.cfg.SettingsFactory - Default entity-mode: pojo
1833 [main] INFO org.hibernate.impl.SessionFactoryImpl - building session factory
1833 [main] DEBUG org.hibernate.impl.SessionFactoryImpl - Session factory constructed with filter configurations : {}
1833 [main] DEBUG org.hibernate.impl.SessionFactoryImpl - instantiating session factory with properties: {java.assistive=ON, java.runtime.name=Java(TM) 2 Runtime Environment, Standard Edition, hibernate.connection.password=ANil85in, sun.boot.library.path=C:\Program Files\IBM\WebSphere Studio\Application Developer\v5.1.2\runtimes\base_v51\java\jre\bin, java.vm.version=1.4.1, hibernate.connection.username=svpa, java.vm.vendor=IBM Corporation, java.vendor.url=http://www.ibm.com/, path.separator=;, java.vm.name=Classic VM, file.encoding.pkg=sun.io, user.country=US, sun.os.patch.level=Service Pack 2, java.vm.specification.name=Java Virtual Machine Specification, user.dir=C:\sf\hibernate3\TestHibernateWeb, java.runtime.version=1.4.1, java.fullversion=J2RE 1.4.1 IBM Windows 32 build cn1411-20031011 (JIT enabled: jitc), java.awt.graphicsenv=sun.awt.Win32GraphicsEnvironment, java.endorsed.dirs=C:\Program Files\IBM\WebSphere Studio\Application Developer\v5.1.2\runtimes\base_v51\java\jre\lib\endorsed, os.arch=x86, java.io.tmpdir=C:\TEMP\, line.separator=
, java.vm.specification.vendor=Sun Microsystems Inc., user.variant=, java.awt.fonts=, os.name=Windows XP, sun.java2d.fontpath=, java.library.path=C:\Program Files\IBM\WebSphere Studio\Application Developer\v5.1.2\runtimes\base_v51\java\bin;.;C:\WINNT\system32;C:\WINNT;C:\Program Files\IBM\WebSphere Studio\Application Developer\v5.1.2\eclipse\jre\bin;C:\PROGRA~1\ORA920\bin;C:\PROGRA~1\ORA920\jre\1.4.2\bin\client;C:\PROGRA~1\ORA920\jre\1.4.2\bin;C:\Program Files\Oracle\jre\1.3.1\bin;C:\Program Files\Oracle\jre\1.1.8\bin;C:\PROGRAM FILES\THINKPAD\UTILITIES;C:\WINNT\system32;C:\WINNT;C:\Progra~1\Serena\CHANGE~1\DIMENS~1\9.1\PROG;c:\progra~1\Merant\DIMENS~1\8.0\PROG;C:\Program Files\Host Integration Server\system;C:\WINNT\System32\Wbem;%PRODDIR%\ISS;C:\PROD\ISS;C:\PROGRAM FILES\RUMBA\SYSTEM;C:\PROGRA~1\DB2\SQLLIB\BIN;C:\PROGRA~1\DB2\SQLLIB\FUNCTION;C:\DOCUMENTS AND SETTINGS\ALL USERS\APPLICATION DATA\NOTES;C:\PROGRAM FILES\NOTES;C:\PROGRA~1\DB2\SQLLIB\SAMPLES\REPL;C:\Program Files\VSEW310;C:\Program Files\VSEW310\Lib;C:\Program Files\VSEW310\qelib;C:\PROD\WSD\SMSNomad\;C:\Program Files\FileNET\IDM;C:\Program Files\Rumba\;C:\Program Files\Protocom\SecureLogin\;gram Files\Protocom\SecureLogin;C:\PROD\WSD\SMSNomad;C:\Program Files\HEWLETT-PACKARD\CLIENT\bin;C:\Program Files\InstallShield\AdminStudio\6.0\ConflictSolver;%PATH%;C:\Program Files\VS60\Common\Tools\WinNT;C:\Program Files\VS60\Common\MSDev98\Bin;C:\Program Files\VS60\Common\Tools;C:\Program Files\VS60\VC98\bin;C:\PROGRA~1\NETMAN~1\NETMAN~1\COMMON, java.specification.name=Java Platform API Specification, java.class.version=48.0, hibernate.connection.pool_size=10, ibm.system.encoding=Cp1252, java.util.prefs.PreferencesFactory=java.util.prefs.WindowsPreferencesFactory, invokedviajava=, os.version=5.1, user.home=C:\Documents and Settings\svpa, user.timezone=, java.awt.printerjob=sun.awt.windows.WPrinterJob, java.specification.version=1.4, file.encoding=Cp1252, hibernate.connection.driver_class=COM.ibm.db2.jdbc.app.DB2Driver, show_sql=true, user.name=svpa, java.class.path=C:\sf\hibernate3\TestHibernateWeb\WebContent\WEB-INF\classes;C:\Program Files\IBM\WebSphere Studio\Application Developer\v5.1.2\runtimes\base_v5\java\jre\lib\rt.jar;C:\Program Files\IBM\WebSphere Studio\Application Developer\v5.1.2\runtimes\base_v5\lib\j2ee.jar;C:\Program Files\IBM\WebSphere Studio\Application Developer\v5.1.2\runtimes\base_v5\lib\servletevent.jar;C:\Program Files\IBM\WebSphere Studio\Application Developer\v5.1.2\runtimes\base_v5\lib\ivjejb35.jar;C:\Program Files\IBM\WebSphere Studio\Application Developer\v5.1.2\runtimes\base_v5\lib\runtime.jar;C:\Documents and Settings\svpa\Desktop\harinder\hibernate3\hibernate312\hibernate-3.1\lib\ant-1.6.5.jar;C:\Documents and Settings\svpa\Desktop\harinder\hibernate3\hibernate312\hibernate-3.1\lib\ant-antlr-1.6.5.jar;C:\Documents and Settings\svpa\Desktop\harinder\hibernate3\hibernate312\hibernate-3.1\lib\ant-junit-1.6.5.jar;C:\Documents and Settings\svpa\Desktop\harinder\hibernate3\hibernate312\hibernate-3.1\lib\ant-launcher-1.6.5.jar;C:\Documents and Settings\svpa\Desktop\harinder\hibernate3\hibernate312\hibernate-3.1\lib\antlr-2.7.6rc1.jar;C:\Documents and Settings\svpa\Desktop\harinder\hibernate3\hibernate312\hibernate-3.1\lib\ant-swing-1.6.5.jar;C:\Documents and Settings\svpa\Desktop\harinder\hibernate3\hibernate312\hibernate-3.1\lib\asm.jar;C:\Documents and Settings\svpa\Desktop\harinder\hibernate3\hibernate312\hibernate-3.1\lib\asm-attrs.jar;C:\Documents and Settings\svpa\Desktop\harinder\hibernate3\hibernate312\hibernate-3.1\lib\c3p0-0.9.0.jar;C:\Documents and Settings\svpa\Desktop\harinder\hibernate3\hibernate312\hibernate-3.1\lib\cglib-2.1.3.jar;C:\Documents and Settings\svpa\Desktop\harinder\hibernate3\hibernate312\hibernate-3.1\lib\cleanimports.jar;C:\Documents and Settings\svpa\Desktop\harinder\hibernate3\hibernate312\hibernate-3.1\lib\commons-collections-2.1.1.jar;C:\Documents and Settings\svpa\Desktop\harinder\hibernate3\hibernate312\hibernate-3.1\lib\commons-logging-1.0.4.jar;C:\Documents and Settings\svpa\Desktop\harinder\hibernate3\hibernate312\hibernate-3.1\lib\concurrent-1.3.2.jar;C:\Documents and Settings\svpa\Desktop\harinder\hibernate3\hibernate312\hibernate-3.1\lib\connector.jar;C:\Documents and Settings\svpa\Desktop\harinder\hibernate3\hibernate312\hibernate-3.1\lib\dom4j-1.6.1.jar;C:\Documents and Settings\svpa\Desktop\harinder\hibernate3\hibernate312\hibernate-3.1\lib\ehcache-1.1.jar;C:\Documents and Settings\svpa\Desktop\harinder\hibernate3\hibernate312\hibernate-3.1\lib\jaas.jar;C:\Documents and Settings\svpa\Desktop\harinder\hibernate3\hibernate312\hibernate-3.1\lib\jacc-1_0-fr.jar;C:\Documents and Settings\svpa\Desktop\harinder\hibernate3\hibernate312\hibernate-3.1\lib\jaxen-1.1-beta-7.jar;C:\Documents and Settings\svpa\Desktop\harinder\hibernate3\hibernate312\hibernate-3.1\lib\jboss-cache.jar;C:\Documents and Settings\svpa\Desktop\harinder\hibernate3\hibernate312\hibernate-3.1\lib\jboss-common.jar;C:\Documents and Settings\svpa\Desktop\harinder\hibernate3\hibernate312\hibernate-3.1\lib\jboss-jmx.jar;C:\Documents and Settings\svpa\Desktop\harinder\hibernate3\hibernate312\hibernate-3.1\lib\jboss-system.jar;C:\Documents and Settings\svpa\Desktop\harinder\hibernate3\hibernate312\hibernate-3.1\lib\jdbc2_0-stdext.jar;C:\Documents and Settings\svpa\Desktop\harinder\hibernate3\hibernate312\hibernate-3.1\lib\jgroups-2.2.8.jar;C:\Documents and Settings\svpa\Desktop\harinder\hibernate3\hibernate312\hibernate-3.1\lib\jta.jar;C:\Documents and Settings\svpa\Desktop\harinder\hibernate3\hibernate312\hibernate-3.1\lib\junit-3.8.1.jar;C:\Documents and Settings\svpa\Desktop\harinder\hibernate3\hibernate312\hibernate-3.1\lib\log4j-1.2.11.jar;C:\Documents and Settings\svpa\Desktop\harinder\hibernate3\hibernate312\hibernate-3.1\lib\oscache-2.1.jar;C:\Documents and Settings\svpa\Desktop\harinder\hibernate3\hibernate312\hibernate-3.1\lib\proxool-0.8.3.jar;C:\Documents and Settings\svpa\Desktop\harinder\hibernate3\hibernate312\hibernate-3.1\lib\swarmcache-1.0rc2.jar;C:\Documents and Settings\svpa\Desktop\harinder\hibernate3\hibernate312\hibernate-3.1\lib\syndiag2.jar;C:\Documents and Settings\svpa\Desktop\harinder\hibernate3\hibernate312\hibernate-3.1\lib\versioncheck.jar;C:\Documents and Settings\svpa\Desktop\harinder\hibernate3\hibernate312\hibernate-3.1\lib\xerces-2.6.2.jar;C:\Documents and Settings\svpa\Desktop\harinder\hibernate3\hibernate312\hibernate-3.1\lib\xml-apis.jar;C:\Program Files\DB2\SQLLIB\java\db2java.zip;C:\Program Files\DB2\SQLLIB\java\db2jcc.jar;C:\Program Files\DB2\SQLLIB\java\db2jcc_license_cu.jar;C:\Documents and Settings\svpa\Desktop\harinder\hibernate3\hibernate312\hibernate-3.1\hibernate3.jar, hibernate.show_sql=true, java.vm.specification.version=1.0, sun.arch.data.model=32, java.home=C:\Program Files\IBM\WebSphere Studio\Application Developer\v5.1.2\runtimes\base_v51\java\jre, hibernate.connection.url=jdbc:db2:SAMPLE, hibernate.dialect=org.hibernate.dialect.DB2Dialect, java.specification.vendor=Sun Microsystems Inc., user.language=en, awt.toolkit=sun.awt.windows.WToolkit, java.vm.info=J2RE 1.4.1 IBM Windows 32 build cn1411-20031011 (JIT enabled: jitc), hibernate.cglib.use_reflection_optimizer=true, java.version=1.4.1, java.ext.dirs=C:\Program Files\IBM\WebSphere Studio\Application Developer\v5.1.2\runtimes\base_v51\java\jre\lib\ext, sun.boot.class.path=C:\Program Files\IBM\WebSphere Studio\Application Developer\v5.1.2\runtimes\base_v51\java\jre\lib\core.jar;C:\Program Files\IBM\WebSphere Studio\Application Developer\v5.1.2\runtimes\base_v51\java\jre\lib\graphics.jar;C:\Program Files\IBM\WebSphere Studio\Application Developer\v5.1.2\runtimes\base_v51\java\jre\lib\security.jar;C:\Program Files\IBM\WebSphere Studio\Application Developer\v5.1.2\runtimes\base_v51\java\jre\lib\server.jar;C:\Program Files\IBM\WebSphere Studio\Application Developer\v5.1.2\runtimes\base_v51\java\jre\lib\xml.jar;C:\Program Files\IBM\WebSphere Studio\Application Developer\v5.1.2\runtimes\base_v51\java\jre\lib\charsets.jar, java.vendor=IBM Corporation, file.separator=\, java.vendor.url.bug=, hibernate.hbm2ddl.auto=validate, java.compiler=jitc, sun.io.unicode.encoding=UnicodeLittle, dialect=org.hibernate.dialect.DB2Dialect}
1863 [main] DEBUG net.sf.ehcache.CacheManager - Creating new CacheManager with default config
1873 [main] DEBUG net.sf.ehcache.CacheManager - Configuring ehcache from classpath.
1933 [main] WARN net.sf.ehcache.config.Configurator - No configuration found. Configuring ehcache from ehcache-failsafe.xml found in the classpath: jar:file:/C:/Documents%20and%20Settings/svpa/Desktop/harinder/hibernate3/hibernate312/hibernate-3.1/lib/ehcache-1.1.jar!/ehcache-failsafe.xml
1953 [main] DEBUG net.sf.ehcache.config.Configuration$DiskStore - Disk Store Path: C:\TEMP\
2474 [main] DEBUG org.hibernate.persister.entity.AbstractEntityPersister - Static SQL for entity: com.sf.hibernate.Employee
2474 [main] DEBUG org.hibernate.persister.entity.AbstractEntityPersister - Version select: select EMPNO from EMPLOYEE where EMPNO =?
2474 [main] DEBUG org.hibernate.persister.entity.AbstractEntityPersister - Snapshot select: select employee_.EMPNO, employee_.FIRSTNME as FIRSTNME0_, employee_.LASTNAME as LASTNAME0_ from EMPLOYEE employee_ where employee_.EMPNO=?
2474 [main] DEBUG org.hibernate.persister.entity.AbstractEntityPersister - Insert 0: insert into EMPLOYEE (FIRSTNME, LASTNAME, EMPNO) values (?, ?, ?)
2474 [main] DEBUG org.hibernate.persister.entity.AbstractEntityPersister - Update 0: update EMPLOYEE set FIRSTNME=?, LASTNAME=? where EMPNO=?
2474 [main] DEBUG org.hibernate.persister.entity.AbstractEntityPersister - Delete 0: delete from EMPLOYEE where EMPNO=?
2504 [main] DEBUG org.hibernate.loader.entity.EntityLoader - Static select for entity com.sf.hibernate.Employee: select employee0_.EMPNO as EMPNO0_0_, employee0_.FIRSTNME as FIRSTNME0_0_, employee0_.LASTNAME as LASTNAME0_0_ from EMPLOYEE employee0_ where employee0_.EMPNO=?
2504 [main] DEBUG org.hibernate.loader.entity.EntityLoader - Static select for entity com.sf.hibernate.Employee: select employee0_.EMPNO as EMPNO0_0_, employee0_.FIRSTNME as FIRSTNME0_0_, employee0_.LASTNAME as LASTNAME0_0_ from EMPLOYEE employee0_ where employee0_.EMPNO=?
2504 [main] DEBUG org.hibernate.loader.entity.EntityLoader - Static select for entity com.sf.hibernate.Employee: select employee0_.EMPNO as EMPNO0_0_, employee0_.FIRSTNME as FIRSTNME0_0_, employee0_.LASTNAME as LASTNAME0_0_ from EMPLOYEE employee0_ where employee0_.EMPNO=? for read only with rs
2504 [main] DEBUG org.hibernate.loader.entity.EntityLoader - Static select for entity com.sf.hibernate.Employee: select employee0_.EMPNO as EMPNO0_0_, employee0_.FIRSTNME as FIRSTNME0_0_, employee0_.LASTNAME as LASTNAME0_0_ from EMPLOYEE employee0_ where employee0_.EMPNO=? for read only with rs
2524 [main] DEBUG org.hibernate.loader.entity.EntityLoader - Static select for action ACTION_MERGE on entity com.sf.hibernate.Employee: select employee0_.EMPNO as EMPNO0_0_, employee0_.FIRSTNME as FIRSTNME0_0_, employee0_.LASTNAME as LASTNAME0_0_ from EMPLOYEE employee0_ where employee0_.EMPNO=?
2524 [main] DEBUG org.hibernate.loader.entity.EntityLoader - Static select for action ACTION_REFRESH on entity com.sf.hibernate.Employee: select employee0_.EMPNO as EMPNO0_0_, employee0_.FIRSTNME as FIRSTNME0_0_, employee0_.LASTNAME as LASTNAME0_0_ from EMPLOYEE employee0_ where employee0_.EMPNO=?
2524 [main] DEBUG org.hibernate.impl.SessionFactoryObjectFactory - initializing class SessionFactoryObjectFactory
2534 [main] DEBUG org.hibernate.impl.SessionFactoryObjectFactory - registered: 8aa3f75709c14a4c0109c14a4ef50000 (unnamed)
2534 [main] INFO org.hibernate.impl.SessionFactoryObjectFactory - Not binding factory to JNDI, no JNDI name configured
2534 [main] DEBUG org.hibernate.impl.SessionFactoryImpl - instantiated session factory
2534 [main] INFO org.hibernate.tool.hbm2ddl.SchemaValidator - Running schema validator
2534 [main] INFO org.hibernate.tool.hbm2ddl.SchemaValidator - fetching database metadata
2534 [main] DEBUG org.hibernate.connection.DriverManagerConnectionProvider - total checked-out connections: 0
2534 [main] DEBUG org.hibernate.connection.DriverManagerConnectionProvider - using pooled JDBC connection, pool size: 0
2534 [main] DEBUG org.hibernate.cfg.Configuration - processing extends queue
2534 [main] DEBUG org.hibernate.cfg.Configuration - processing collection mappings
2534 [main] DEBUG org.hibernate.cfg.Configuration - processing native query and ResultSetMapping mappings
2534 [main] DEBUG org.hibernate.cfg.Configuration - processing association property references
2534 [main] DEBUG org.hibernate.cfg.Configuration - processing foreign key constraints
2875 [main] INFO org.hibernate.tool.hbm2ddl.TableMetadata - table found: SVPA.EMPLOYEE
2875 [main] INFO org.hibernate.tool.hbm2ddl.TableMetadata - columns: [sex, lastname, firstnme, edlevel, workdept, job, midinit, phoneno, bonus, hiredate, comm, birthdate, salary, empno]
2875 [main] ERROR org.hibernate.tool.hbm2ddl.SchemaValidator - Error closing connection
COM.ibm.db2.jdbc.DB2Exception: [IBM][CLI Driver] CLI0116E Invalid transaction state. SQLSTATE=25000
at COM.ibm.db2.jdbc.app.SQLExceptionGenerator.throw_SQLException(Unknown Source)
at COM.ibm.db2.jdbc.app.SQLExceptionGenerator.check_return_code(Unknown Source)
at COM.ibm.db2.jdbc.app.DB2Connection.close2(Unknown Source)
at COM.ibm.db2.jdbc.app.DB2Connection.close(Unknown Source)
at org.hibernate.tool.hbm2ddl.SchemaValidator.validate(SchemaValidator.java:125)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:296)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1176)
at com.sf.hibernate.MainClass.main(MainClass.java:26)
org.hibernate.HibernateException: Wrong column type: EMPNO, expected: varchar(255)
at org.hibernate.mapping.Table.validateColumns(Table.java:219)
at org.hibernate.cfg.Configuration.validateSchema(Configuration.java:965)
at org.hibernate.tool.hbm2ddl.SchemaValidator.validate(SchemaValidator.java:116)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:296)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1176)
at com.sf.hibernate.MainClass.main(MainClass.java:26)

Name and version of the database you are using:
DB2 Version 8.2
Test is on Websphere- WSAD 512
The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:
# Set root logger level to DEBUG and its only appender to A1.
log4j.rootLogger=debug, A1

# A1 is set to be a ConsoleAppender.
log4j.appender.A1=org.apache.log4j.ConsoleAppender

# A1 uses PatternLayout.
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n

log4j.logger.org.apache.commons.digester=INFO


Top
 Profile  
 
 Post subject: Error display nodebug->Wrong column type: EMPNO, expected
PostPosted: Fri Mar 03, 2006 2:29 pm 
Newbie

Joined: Fri Mar 03, 2006 2:11 pm
Posts: 16
org.hibernate.HibernateException: Wrong column type: EMPNO, expected: varchar(255)
at org.hibernate.mapping.Table.validateColumns(Table.java:219)
at org.hibernate.cfg.Configuration.validateSchema(Configuration.java:965)
at org.hibernate.tool.hbm2ddl.SchemaValidator.validate(SchemaValidator.java:116)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:296)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1176)
at com.sf.hibernate.MainClass.main(MainClass.java:26)


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 03, 2006 3:20 pm 
Expert
Expert

Joined: Mon Jan 09, 2006 5:01 pm
Posts: 311
Location: Sacramento, CA
change your type="long" in the <id... empNo

_________________
-JT

If you find my replies helpful, please rate by clicking 'Y' on them. I appreciate it.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 03, 2006 3:40 pm 
Newbie

Joined: Fri Mar 03, 2006 2:11 pm
Posts: 16
Here is the error when changed to 'long' as suggested. Please note that the DB2 Table has that column 'EMPNO' as varchar(6). I tried but it did not fix. When I put 'long' here is the error reoported:

org.hibernate.HibernateException: Wrong column type: EMPNO, expected: bigint
at org.hibernate.mapping.Table.validateColumns(Table.java:219)
at org.hibernate.cfg.Configuration.validateSchema(Configuration.java:965)
at org.hibernate.tool.hbm2ddl.SchemaValidator.validate(SchemaValidator.java:116)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:296)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1176)
at com.sf.hibernate.MainClass.main(MainClass.java:27)


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 03, 2006 3:43 pm 
Expert
Expert

Joined: Mon Jan 09, 2006 5:01 pm
Posts: 311
Location: Sacramento, CA
try bigint.

_________________
-JT

If you find my replies helpful, please rate by clicking 'Y' on them. I appreciate it.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 03, 2006 3:56 pm 
Newbie

Joined: Fri Mar 03, 2006 2:11 pm
Posts: 16
'bigint' is not a type hiberante accept for 'type' tag. 'bigint' will work only when we define column attribute with 'sql-type'. This will happen only when hibernate.hbm2ddl.auto is 'validate'. If this (hibernate.hbm2ddl.auto) value is 'update' I am able to read data from tables. I tried to debug using hibernate source code and found that 'Table' class has a method to 'validateColumns' the schema which compares the mapping and the DB2 table schema and it is failing there. With bigint:

org.hibernate.HibernateException: Wrong column type: EMPNO, expected: bigint
at org.hibernate.mapping.Table.validateColumns(Table.java:219)
at org.hibernate.cfg.Configuration.validateSchema(Configuration.java:965)
at org.hibernate.tool.hbm2ddl.SchemaValidator.validate(SchemaValidator.java:116)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:296)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1176)
at com.sf.hibernate.MainClass.main(MainClass.java:27)
*********************
When I change mapping to (string is supposed to be mapped to VARCHAR:

<id name="empNo" type="string">
<column name="EMPNO" sql-type="VARCHAR"/>
<generator class="seqhilo">
<param name="sequence">empseq</param>
<param name="max_lo">100</param>
</generator>
</id>

Error is:

org.hibernate.HibernateException: Wrong column type: EMPNO, expected: VARCHAR
at org.hibernate.mapping.Table.validateColumns(Table.java:219)
at org.hibernate.cfg.Configuration.validateSchema(Configuration.java:965)
at org.hibernate.tool.hbm2ddl.SchemaValidator.validate(SchemaValidator.java:116)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:296)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1176)
at com.sf.hibernate.MainClass.main(MainClass.java:27)


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 03, 2006 4:09 pm 
Expert
Expert

Joined: Mon Jan 09, 2006 5:01 pm
Posts: 311
Location: Sacramento, CA
here is a working sample that you can model after (for Oracle):

<id name="ADDRESS_ID" column="ADDRESS_ID"
type="java.lang.Long" unsaved-value="null">
<generator class="sequence">
<param name="sequence">ADDRESS_SEQ</param>
<param name="parameters">INCREMENT BY 1 START WITH 1</param>
</generator>
</id>

and in the ADDRESS table "ADDRESS_ID number primary key,"

I think you have a problem where the sequence is generating a number and you are telling it in hibernate that is should be a string.

_________________
-JT

If you find my replies helpful, please rate by clicking 'Y' on them. I appreciate it.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 03, 2006 4:28 pm 
Newbie

Joined: Fri Mar 03, 2006 2:11 pm
Posts: 16
Probably I did not explain properly my problem. Please note that I am not generating any data for Sequence. I am using just default config file and generate attribute is used only to avoid XML file validation fail against DTD. If I do nto give 'generate' tag in WSAD it reports error. Note that I already have data in DB2 table 'Employee'. I just wanted to read (using simple SELECT clause - I am using Native SQL Query) the data from table. Before reading I want Hibernate to validate the schema. Problem is reported when Hibernate is validating data. Please see the method below where it is failing. Probably if you have time you may try reading data with any table but use:
hibernate.hbm2ddl.auto=validate
and check to see if you have same problem.
************Hibernate method from Table class- Source code from Hibernate***********
public void validateColumns(Dialect dialect, Mapping mapping, TableMetadata tableInfo) {
Iterator iter = getColumnIterator();
while ( iter.hasNext() ) {
Column col = ( Column ) iter.next();

ColumnMetadata columnInfo = tableInfo.getColumnMetadata( col.getName() );

if ( columnInfo == null ) {
throw new HibernateException( "Missing column: " + col.getName() );
}
else {
final boolean typesMatch = col.getSqlType(dialect, mapping)
.startsWith( columnInfo.getTypeName().toLowerCase() )
|| columnInfo.getTypeCode() == col.getSqlTypeCode(mapping);
if ( !typesMatch ) {
throw new HibernateException(
"Wrong column type: " + col.getName() +
", expected: " + col.getSqlType(dialect, mapping)
);
}
}
}

}
**************************************************


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 03, 2006 4:58 pm 
Expert
Expert

Joined: Mon Jan 09, 2006 5:01 pm
Posts: 311
Location: Sacramento, CA
the stack is showing the it is failing on schema validation... a mismatch between number and string. That is where you want to concentrate your effort. So if it is defined as a VARCHAR in the db, then use String if number, then use Long...Also note, that the type is optional and hibernate should be able to determine it from reflection on your java class.

Also if you are not "inserting" data then look at the section in the reference.pdf that talks about legacy data and existing PK's...
w/ composite-id
page 54: http://www.hibernate.org/hib_docs/v3/reference/en/pdf/hibernate_reference.pdf

Also quoted from the reference.pdf:

Quote:
typename could be:
1. The name of a Hibernate basic type (eg. integer, string, character, date, timestamp, float,
binary, serializable, object, blob).
2. The name of a Java class with a default basic type (eg. int, float, char, java.lang.String,
java.util.Date, java.lang.Integer, java.sql.Clob).
3. The name of a serializable Java class.
4. The class name of a custom type (eg. com.illflow.type.MyCustomType).


Hope this helps...

_________________
-JT

If you find my replies helpful, please rate by clicking 'Y' on them. I appreciate it.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Mar 04, 2006 2:57 pm 
Newbie

Joined: Fri Mar 03, 2006 2:11 pm
Posts: 16
Here is what I found by debugging:
Column 'empno' in table 'Employee' is declared as 'CHAR'. In hibernate if we do not declare the sql-type or attribute type, it defaults to String or VARCHAR(255). As hibernate validation routine compares using this code:

*****************Table.java- validateColumns - method***********
final boolean typesMatch = col.getSqlType(dialect, mapping)
.startsWith( columnInfo.getTypeName().toLowerCase() )
|| columnInfo.getTypeCode() == col.getSqlTypeCode(mapping);
if ( !typesMatch ) {
throw new HibernateException(........
**********************************************


1. between VARCHAR(255), which is default and the METADATA and its type gathered from DB2Dialect, which is 'CHAR'--->col.getSqlType(dialect, mapping)= "varchar(255)" - Hibernate default
columnInfo.getTypeName().toLowerCase()= "char" -> value returned by DB2 driver

This code will return false

2. In this part of the code Hibernate compares between mapped information and the Metadata returned by DB2 driver in numbers or code for Types:
columnInfo.getTypeCode() will return 1 (CHAR from DB2 table)
col.getSqlTypeCode(mapping) will return 12 (String - Hibernate default)
columnInfo.getTypeCode() == col.getSqlTypeCode(mapping)

This code too will return false. As both return false values Hibernate throws an exception with error message:

org.hibernate.HibernateException: Wrong column type: EMPNO, expected: varchar(255)
********************Resolution****************
I hardcoded the sql-type='char' did the trick. Please note the lower case. If we use upper case it will fail. I think case issue should have been addressed by Hibernate code by converting values either to lower or upper case instead of asking users to use always lower case. Here is the mapping part I have changed to make it work:

<class name="com.ibm.hibernate.Employee" table="EMPLOYEE">
<id name="empno" type="string">
<column name="EMPNO" sql-type="char"/>
</id>
<property name="firstNme">
<column name="FIRSTNME" />
</property>
<property name="lastName">
<column name="LASTNAME"/>
</property>


</class>

It hasa nothing to do with sequence generation as I mentioned earlier this is related to sql-type between Hibernate default value and DB2 dialect in case of validation. Not sure if this is an issue with Hibernate code and to be addressed or not. Thanks for all the help, analysis and feedback


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