Hi,
I am using Hibernate 2.1 with Tomcat 5.5.7, Java 1.5.0_01, and Oracle 9i. We are trying to implement Hibernate in an existing application. Our key generation strategy prior to Hibernate was to use a static random number generator to create our keys. The keys are represented as varchar2(10) in the DB and as Strings in our data objects. I am attempting to create a custom IdentifierGenerator implementation that uses this random number generator and returns a String. I am getting a mapping exception indicating that my dialect does not support Identity generation. I've seen this in the documentation, but I am not sure why Hibernate is interpreting my custom generator as trying to use Identity generation. Any light you all could shed on this would be greatly appreciated.
Hibernate version: 2.1
Mapping documents:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN" "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<class name="com.sas.edu.educentral.edusa.beans.DiscountProgram" table="DISC_PGM">
<!-- ID generated by custom class (String). -->
<id name="ID" type="java.lang.String" column="DISC_PGM_ID" unsaved-value="null" >
<!-- <column name="DISC_PGM_ID" sql-type="varchar2(10)" not-null="true"/> -->
<generator class="com.sas.edu.educentral.system.EduCentralIdentifierGenerator"/>
<!--<generator class="native"/>-->
</id>
<property name="code">
<column name="DISC_PGM_CODE" length="20" not-null="true"/>
</property>
<property name="name">
<column name="DISC_PGM_NAME" length="100" not-null="true"/>
</property>
<property name="type">
<column name="DISC_PGM_TYPE" length="1" not-null="true"/>
</property>
<property name="oneOffer">
<column name="ONE_OFFER" length="1" not-null="true"/>
</property>
<property name="adminLevel">
<column name="ADMIN_LEVEL" length="1" not-null="true"/>
</property>
<property name="publicOnsite">
<column name="PUBLIC_ONSITE" length="1" not-null="true"/>
</property>
<property name="invoiceCredit">
<column name="INV_CRED" length="1" not-null="true"/>
</property>
<property name="startDate">
<column name="START_DATE" not-null="true"/>
</property>
<property name="endDate">
<column name="END_DATE" not-null="false"/>
</property>
<property name="created">
<column name="CREATED" not-null="true"/>
</property>
<property name="createdBy">
<column name="CREATEDBY" length="20" not-null="true"/>
</property>
<property name="lastUpdated">
<column name="LASTUPDATED" not-null="true"/>
</property>
<property name="lastUpdatedBy">
<column name="LASTUPDATEDBY" not-null="true"/>
</property>
</class>
</hibernate-mapping>
Custom Generator:
public class EduCentralIdentifierGenerator extends IdentityGenerator {
/**
* Empty Constructor.
*
* @author ryalbe
*/
public EduCentralIdentifierGenerator() {}
/**
* Generate a new identifier.
* @param session *not used*
* @param object the entity or toplevel collection for which the id is being generated
* @return Serializable a new identifier
* @throws SQLException
* @throws HibernateException
*/
public Serializable generate(SessionImplementor session, Object object) throws SQLException, HibernateException {
return new Integer(RandomKey.generateNext()).toString();
}
}
Stack trace output:
11:06:35,660 INFO Environment:478 - Hibernate 2.1.7
11:06:35,660 INFO Environment:507 - hibernate.properties not found
11:06:35,676 INFO Environment:538 - using CGLIB reflection optimizer
11:06:35,676 INFO Environment:567 - using JDK 1.4 java.sql.Timestamp handling
11:06:35,676 INFO Configuration:900 - configuring from resource: /hibernate.cfg.xml
11:06:35,676 INFO Configuration:872 - Configuration resource: /hibernate.cfg.xml
11:06:35,770 DEBUG DTDEntityResolver:20 - trying to locate
http://hibernate.sourceforge.net/hibern ... on-2.0.dtd in classpath under net/sf/hibernate/
11:06:35,785 DEBUG DTDEntityResolver:29 - found
http://hibernate.sourceforge.net/hibern ... on-2.0.dtd in classpath
11:06:35,832 DEBUG Configuration:858 - query.substitutions=true 1, false 0, yes 'Y', no 'N'
11:06:35,832 DEBUG Configuration:858 - dialect=net.sf.hibernate.dialect.OracleDialect
11:06:35,832 DEBUG Configuration:858 - connection.driver_class=oracle.jdbc.driver.OracleDriver
11:06:35,832 DEBUG Configuration:858 - connection.username=eduit
11:06:35,832 DEBUG Configuration:858 - connection.password=db4all
11:06:35,832 DEBUG Configuration:858 - connection.url=jdbc:oracle:thin:@ordbdds.unx.sas.com:6650:EDUD
11:06:35,832 DEBUG Configuration:858 - dbcp.maxActive=100
11:06:35,832 DEBUG Configuration:858 - dbcp.maxIdle=10
11:06:35,832 DEBUG Configuration:858 - dbcp.whenExhaustedAction=1
11:06:35,832 DEBUG Configuration:858 - dbcp.maxWait=120000
11:06:35,848 DEBUG Configuration:858 - dbcp.ps.maxActive=100
11:06:35,848 DEBUG Configuration:858 - dbcp.ps.maxIdle=10
11:06:35,848 DEBUG Configuration:858 - dbcp.ps.whenExhaustedAction=1
11:06:35,848 DEBUG Configuration:858 - dbcp.ps.maxWait=120000
11:06:35,848 DEBUG Configuration:858 - hibernate.connection.provider_class=net.sf.hibernate.connection.DBCPConnectionProvider
11:06:35,848 DEBUG Configuration:858 - show_sql=true
11:06:35,848 DEBUG Configuration:858 - jdbc.batch_size=0
11:06:35,848 DEBUG Configuration:858 - jdbc.batch_versioned_data=true
11:06:35,848 DEBUG Configuration:858 - jdbc.use_streams_for_binary=true
11:06:35,848 DEBUG Configuration:858 - max_fetch_depth=1
11:06:35,848 DEBUG Configuration:858 - cache.region_prefix=hibernate.test
11:06:35,848 DEBUG Configuration:858 - cache.use_query_cache=true
11:06:35,848 DEBUG Configuration:858 - cache.provider_class=net.sf.hibernate.cache.EhCacheProvider
11:06:35,848 DEBUG Configuration:1017 - null<-org.dom4j.tree.DefaultAttribute@a620f5 [Attribute: name resource value "DiscountProgram.hbm.xml"]
11:06:35,848 INFO Configuration:331 - Mapping resource: DiscountProgram.hbm.xml
11:06:35,863 DEBUG DTDEntityResolver:20 - trying to locate
http://hibernate.sourceforge.net/hibern ... ng-2.0.dtd in classpath under net/sf/hibernate/
11:06:35,863 DEBUG DTDEntityResolver:29 - found
http://hibernate.sourceforge.net/hibern ... ng-2.0.dtd in classpath
11:06:36,004 INFO Binder:230 - Mapping class: com.sas.edu.educentral.edusa.beans.DiscountProgram -> DISC_PGM
11:06:36,113 DEBUG Binder:487 - Mapped property: ID -> DISC_PGM_ID, type: string
11:06:36,160 DEBUG Binder:487 - Mapped property: code -> DISC_PGM_CODE, type: string
11:06:36,160 DEBUG Binder:487 - Mapped property: name -> DISC_PGM_NAME, type: string
11:06:36,160 DEBUG Binder:487 - Mapped property: type -> DISC_PGM_TYPE, type: string
11:06:36,160 DEBUG Binder:487 - Mapped property: oneOffer -> ONE_OFFER, type: string
11:06:36,160 DEBUG Binder:487 - Mapped property: adminLevel -> ADMIN_LEVEL, type: string
11:06:36,160 DEBUG Binder:487 - Mapped property: publicOnsite -> PUBLIC_ONSITE, type: string
11:06:36,160 DEBUG Binder:487 - Mapped property: invoiceCredit -> INV_CRED, type: string
11:06:36,160 DEBUG Binder:487 - Mapped property: startDate -> START_DATE, type: calendar
11:06:36,160 DEBUG Binder:487 - Mapped property: endDate -> END_DATE, type: calendar
11:06:36,160 DEBUG Binder:487 - Mapped property: created -> CREATED, type: calendar
11:06:36,160 DEBUG Binder:487 - Mapped property: createdBy -> CREATEDBY, type: string
11:06:36,176 DEBUG Binder:487 - Mapped property: lastUpdated -> LASTUPDATED, type: calendar
11:06:36,176 DEBUG Binder:487 - Mapped property: lastUpdatedBy -> LASTUPDATEDBY, type: string
11:06:36,176 INFO Configuration:1058 - Configured SessionFactory: null
11:06:36,176 DEBUG Configuration:1059 - properties: {hibernate.jdbc.batch_versioned_data=true, show_sql=true, java.vendor=Sun Microsystems Inc., catalina.base=c:\EduRewrite\tomcat, hibernate.connection.url=jdbc:oracle:thin:@ordbdds.unx.sas.com:6650:EDUD, sun.management.compiler=HotSpot Client Compiler, catalina.useNaming=true, hibernate.dbcp.ps.maxWait=120000, os.name=Windows XP, sun.boot.class.path=C:\Program Files\Java\jre1.5.0_01\lib\rt.jar;C:\Program Files\Java\jre1.5.0_01\lib\i18n.jar;C:\Program Files\Java\jre1.5.0_01\lib\sunrsasign.jar;C:\Program Files\Java\jre1.5.0_01\lib\jsse.jar;C:\Program Files\Java\jre1.5.0_01\lib\jce.jar;C:\Program Files\Java\jre1.5.0_01\lib\charsets.jar;C:\Program Files\Java\jre1.5.0_01\classes, sun.desktop=windows, hibernate.dbcp.maxWait=120000, java.vm.specification.vendor=Sun Microsystems Inc., java.runtime.version=1.5.0_01-b08, hibernate.cache.provider_class=net.sf.hibernate.cache.EhCacheProvider, user.name=SYSTEM, shared.loader=${catalina.base}/shared/classes,${catalina.base}/shared/lib/*.jar, hibernate.dbcp.ps.maxIdle=10, tomcat.util.buf.StringCache.byte.enabled=true, connection.driver_class=oracle.jdbc.driver.OracleDriver, hibernate.dbcp.maxActive=100, hibernate.dbcp.maxIdle=10, user.language=en, java.naming.factory.initial=org.apache.naming.java.javaURLContextFactory, sun.boot.library.path=C:\Program Files\Java\jre1.5.0_01\bin, dialect=net.sf.hibernate.dialect.OracleDialect, max_fetch_depth=1, java.version=1.5.0_01, user.timezone=America/New_York, dbcp.ps.whenExhaustedAction=1, jdbc.batch_size=0, sun.arch.data.model=32, java.endorsed.dirs=c:\EduRewrite\tomcat\common\endorsed, sun.cpu.isalist=, sun.jnu.encoding=Cp1252, file.encoding.pkg=sun.io, cache.use_query_cache=true, package.access=sun.,org.apache.catalina.,org.apache.coyote.,org.apache.tomcat.,org.apache.jasper.,sun.beans., file.separator=\, java.specification.name=Java Platform API Specification, hibernate.cglib.use_reflection_optimizer=true, java.class.version=49.0, user.country=US, connection.url=jdbc:oracle:thin:@ordbdds.unx.sas.com:6650:EDUD, java.home=C:\Program Files\Java\jre1.5.0_01, hibernate.dbcp.whenExhaustedAction=1, java.vm.info=mixed mode, sharing, hibernate.dbcp.ps.whenExhaustedAction=1, os.version=5.1, path.separator=;, connection.password=db4all, java.vm.version=1.5.0_01-b08, hibernate.max_fetch_depth=1, hibernate.connection.password=db4all, user.variant=, hibernate.jdbc.batch_size=0, java.awt.printerjob=sun.awt.windows.WPrinterJob, sun.io.unicode.encoding=UnicodeLittle, awt.toolkit=sun.awt.windows.WToolkit, hibernate.connection.username=eduit, cache.region_prefix=hibernate.test, jdbc.use_streams_for_binary=true, package.definition=sun.,java.,org.apache.catalina.,org.apache.coyote.,org.apache.tomcat.,org.apache.jasper., hibernate.cache.region_prefix=hibernate.test, dbcp.maxWait=120000, dbcp.maxActive=100, java.naming.factory.url.pkgs=org.apache.naming, query.substitutions=true 1, false 0, yes 'Y', no 'N', user.home=C:\Documents and Settings\dtaservices, hibernate.query.substitutions=true 1, false 0, yes 'Y', no 'N', java.specification.vendor=Sun Microsystems Inc., hibernate.dbcp.ps.maxActive=100, java.library.path=c:\EduRewrite\tomcat\bin;.;C:\WINNT\system32;C:\WINNT;C:\oracle\ora92\bin;C:\WINNT\system32;C:\WINNT;C:\WINNT\System32\Wbem;C:\Program Files\Hummingbird\Connectivity\7.10\Accessories\;C:\Program Files\Java\jdk1.5.0_01\bin;c:\php;C:\Program Files\PRISM;c:\C:\Program Files\Java\jdk1.5.0_01\jre\bin;C:\Program Files\UltraEdit;c:\EduRewrite\apache-ant-1.5.4\bin, java.vendor.url=http://java.sun.com/, hibernate.connection.driver_class=oracle.jdbc.driver.OracleDriver, connection.username=eduit, java.vm.vendor=Sun Microsystems Inc., hibernate.dialect=net.sf.hibernate.dialect.OracleDialect, hibernate.jdbc.use_streams_for_binary=true, common.loader=${catalina.home}/common/classes,${catalina.home}/common/i18n/*.jar,${catalina.home}/common/endorsed/*.jar,${catalina.home}/common/lib/*.jar, java.runtime.name=Java(TM) 2 Runtime Environment, Standard Edition, java.class.path=c:\EduRewrite\tomcat\bin\bootstrap.jar, dbcp.maxIdle=10, java.vm.specification.name=Java Virtual Machine Specification, java.vm.specification.version=1.0, catalina.home=c:\EduRewrite\tomcat, hibernate.cache.use_query_cache=true, sun.cpu.endian=little, sun.os.patch.level=Service Pack 2, hibernate.connection.provider_class=net.sf.hibernate.connection.DBCPConnectionProvider, java.io.tmpdir=c:\EduRewrite\tomcat\temp, java.vendor.url.bug=http://java.sun.com/cgi-bin/bugreport.cgi, server.loader=${catalina.home}/server/classes,${catalina.home}/server/lib/*.jar, os.arch=x86, java.awt.graphicsenv=sun.awt.Win32GraphicsEnvironment, java.ext.dirs=C:\Program Files\Java\jre1.5.0_01\lib\ext, dbcp.ps.maxActive=100, user.dir=C:\WINNT\system32, line.separator=
, java.vm.name=Java HotSpot(TM) Client VM, dbcp.ps.maxWait=120000, dbcp.whenExhaustedAction=1, cache.provider_class=net.sf.hibernate.cache.EhCacheProvider, file.encoding=Cp1252, java.specification.version=1.5, jdbc.batch_versioned_data=true, hibernate.show_sql=true, dbcp.ps.maxIdle=10}
11:06:36,176 INFO Configuration:632 - processing one-to-many association mappings
11:06:36,176 INFO Configuration:641 - processing one-to-one association property references
11:06:36,176 INFO Configuration:666 - processing foreign key constraints
11:06:36,223 INFO Dialect:86 - Using dialect: net.sf.hibernate.dialect.OracleDialect
11:06:36,238 DEBUG SQLExceptionConverterFactory:49 - Using dialect defined converter
11:06:36,254 INFO SettingsFactory:70 - Maximim outer join fetch depth: 1
11:06:36,254 INFO SettingsFactory:74 - Use outer join fetching: true
11:06:36,254 INFO ConnectionProviderFactory:53 - Initializing connection provider: net.sf.hibernate.connection.DBCPConnectionProvider
11:06:36,270 INFO DBCPConnectionProvider:45 - DBCP using driver: oracle.jdbc.driver.OracleDriver at URL: jdbc:oracle:thin:@ordbdds.unx.sas.com:6650:EDUD
11:06:36,270 INFO DBCPConnectionProvider:46 - Connection properties: {user=eduit, password=db4all}
11:06:36,285 INFO DBCPConnectionProvider:83 - DBCP prepared statement pooling enabled.
11:06:36,332 INFO TransactionManagerLookupFactory:33 - No TransactionManagerLookup configured (in JTA environment, use of process level read-write cache is not recommended)
11:06:36,332 INFO DBCPConnectionProvider:127 - Retrieving connection from DBCP connection pool...
11:06:36,520 INFO DBCPConnectionProvider:133 - Connection retrieved from DBCP Connection pool.
11:06:36,520 INFO DBCPConnectionProvider:134 - Number of connections used: 1
11:06:36,520 INFO DBCPConnectionProvider:135 - Number of connections available: 0
11:06:36,535 INFO DBCPConnectionProvider:141 - Returning connection to DBCP connection pool...
11:06:36,535 INFO DBCPConnectionProvider:143 - Connection returned to DBCP connection pool.
11:06:36,551 INFO DBCPConnectionProvider:144 - Number of connections used: 0
11:06:36,551 INFO DBCPConnectionProvider:145 - Number of connections available: 1
11:06:36,551 INFO SettingsFactory:114 - Use scrollable result sets: true
11:06:36,551 INFO SettingsFactory:117 - Use JDBC3 getGeneratedKeys(): false
11:06:36,551 INFO SettingsFactory:120 - Optimize cache for minimal puts: false
11:06:36,551 INFO SettingsFactory:126 - echoing all SQL to stdout
11:06:36,551 INFO SettingsFactory:129 - Query language substitutions: {no='N', true=1, yes='Y', false=0}
11:06:36,551 INFO SettingsFactory:140 - cache provider: net.sf.hibernate.cache.EhCacheProvider
11:06:36,551 INFO SettingsFactory:152 - query cache factory: net.sf.hibernate.cache.StandardQueryCacheFactory
11:06:36,566 INFO Configuration:1121 - instantiating and configuring caches
11:06:36,785 INFO SessionFactoryImpl:119 - building session factory
11:06:36,801 DEBUG SessionFactoryImpl:125 - instantiating session factory with properties: {hibernate.jdbc.batch_versioned_data=true, show_sql=true, java.vendor=Sun Microsystems Inc., catalina.base=c:\EduRewrite\tomcat, hibernate.connection.url=jdbc:oracle:thin:@ordbdds.unx.sas.com:6650:EDUD, sun.management.compiler=HotSpot Client Compiler, catalina.useNaming=true, hibernate.dbcp.ps.maxWait=120000, os.name=Windows XP, sun.boot.class.path=C:\Program Files\Java\jre1.5.0_01\lib\rt.jar;C:\Program Files\Java\jre1.5.0_01\lib\i18n.jar;C:\Program Files\Java\jre1.5.0_01\lib\sunrsasign.jar;C:\Program Files\Java\jre1.5.0_01\lib\jsse.jar;C:\Program Files\Java\jre1.5.0_01\lib\jce.jar;C:\Program Files\Java\jre1.5.0_01\lib\charsets.jar;C:\Program Files\Java\jre1.5.0_01\classes, sun.desktop=windows, hibernate.dbcp.maxWait=120000, java.vm.specification.vendor=Sun Microsystems Inc., java.runtime.version=1.5.0_01-b08, hibernate.cache.provider_class=net.sf.hibernate.cache.EhCacheProvider, user.name=SYSTEM, shared.loader=${catalina.base}/shared/classes,${catalina.base}/shared/lib/*.jar, hibernate.dbcp.ps.maxIdle=10, tomcat.util.buf.StringCache.byte.enabled=true, connection.driver_class=oracle.jdbc.driver.OracleDriver, hibernate.dbcp.maxActive=100, hibernate.dbcp.maxIdle=10, user.language=en, java.naming.factory.initial=org.apache.naming.java.javaURLContextFactory, sun.boot.library.path=C:\Program Files\Java\jre1.5.0_01\bin, dialect=net.sf.hibernate.dialect.OracleDialect, max_fetch_depth=1, java.version=1.5.0_01, user.timezone=America/New_York, dbcp.ps.whenExhaustedAction=1, jdbc.batch_size=0, sun.arch.data.model=32, java.endorsed.dirs=c:\EduRewrite\tomcat\common\endorsed, sun.cpu.isalist=, sun.jnu.encoding=Cp1252, file.encoding.pkg=sun.io, cache.use_query_cache=true, package.access=sun.,org.apache.catalina.,org.apache.coyote.,org.apache.tomcat.,org.apache.jasper.,sun.beans., file.separator=\, java.specification.name=Java Platform API Specification, hibernate.cglib.use_reflection_optimizer=true, java.class.version=49.0, user.country=US, connection.url=jdbc:oracle:thin:@ordbdds.unx.sas.com:6650:EDUD, java.home=C:\Program Files\Java\jre1.5.0_01, hibernate.dbcp.whenExhaustedAction=1, java.vm.info=mixed mode, sharing, hibernate.dbcp.ps.whenExhaustedAction=1, os.version=5.1, path.separator=;, connection.password=db4all, java.vm.version=1.5.0_01-b08, hibernate.max_fetch_depth=1, hibernate.connection.password=db4all, user.variant=, hibernate.jdbc.batch_size=0, java.awt.printerjob=sun.awt.windows.WPrinterJob, sun.io.unicode.encoding=UnicodeLittle, awt.toolkit=sun.awt.windows.WToolkit, hibernate.connection.username=eduit, cache.region_prefix=hibernate.test, jdbc.use_streams_for_binary=true, package.definition=sun.,java.,org.apache.catalina.,org.apache.coyote.,org.apache.tomcat.,org.apache.jasper., hibernate.cache.region_prefix=hibernate.test, dbcp.maxWait=120000, dbcp.maxActive=100, java.naming.factory.url.pkgs=org.apache.naming, query.substitutions=true 1, false 0, yes 'Y', no 'N', user.home=C:\Documents and Settings\dtaservices, hibernate.query.substitutions=true 1, false 0, yes 'Y', no 'N', java.specification.vendor=Sun Microsystems Inc., hibernate.dbcp.ps.maxActive=100, java.library.path=c:\EduRewrite\tomcat\bin;.;C:\WINNT\system32;C:\WINNT;C:\oracle\ora92\bin;C:\WINNT\system32;C:\WINNT;C:\WINNT\System32\Wbem;C:\Program Files\Hummingbird\Connectivity\7.10\Accessories\;C:\Program Files\Java\jdk1.5.0_01\bin;c:\php;C:\Program Files\PRISM;c:\C:\Program Files\Java\jdk1.5.0_01\jre\bin;C:\Program Files\UltraEdit;c:\EduRewrite\apache-ant-1.5.4\bin, java.vendor.url=http://java.sun.com/, hibernate.connection.driver_class=oracle.jdbc.driver.OracleDriver, connection.username=eduit, java.vm.vendor=Sun Microsystems Inc., hibernate.dialect=net.sf.hibernate.dialect.OracleDialect, hibernate.jdbc.use_streams_for_binary=true, common.loader=${catalina.home}/common/classes,${catalina.home}/common/i18n/*.jar,${catalina.home}/common/endorsed/*.jar,${catalina.home}/common/lib/*.jar, java.runtime.name=Java(TM) 2 Runtime Environment, Standard Edition, java.class.path=c:\EduRewrite\tomcat\bin\bootstrap.jar, dbcp.maxIdle=10, java.vm.specification.name=Java Virtual Machine Specification, java.vm.specification.version=1.0, catalina.home=c:\EduRewrite\tomcat, hibernate.cache.use_query_cache=true, sun.cpu.endian=little, sun.os.patch.level=Service Pack 2, hibernate.connection.provider_class=net.sf.hibernate.connection.DBCPConnectionProvider, java.io.tmpdir=c:\EduRewrite\tomcat\temp, java.vendor.url.bug=http://java.sun.com/cgi-bin/bugreport.cgi, server.loader=${catalina.home}/server/classes,${catalina.home}/server/lib/*.jar, os.arch=x86, java.awt.graphicsenv=sun.awt.Win32GraphicsEnvironment, java.ext.dirs=C:\Program Files\Java\jre1.5.0_01\lib\ext, dbcp.ps.maxActive=100, user.dir=C:\WINNT\system32, line.separator=
, java.vm.name=Java HotSpot(TM) Client VM, dbcp.ps.maxWait=120000, dbcp.whenExhaustedAction=1, cache.provider_class=net.sf.hibernate.cache.EhCacheProvider, file.encoding=Cp1252, java.specification.version=1.5, jdbc.batch_versioned_data=true, hibernate.show_sql=true, dbcp.ps.maxIdle=10}
net.sf.hibernate.MappingException: Dialect does not support identity key generation
at net.sf.hibernate.dialect.Dialect.getIdentitySelectString(Dialect.java:297)
at net.sf.hibernate.persister.AbstractEntityPersister.<init>(AbstractEntityPersister.java:647)
at net.sf.hibernate.persister.EntityPersister.<init>(EntityPersister.java:692)
at net.sf.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:42)
at net.sf.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:137)
at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:796)
at com.sas.edu.educentral.system.dbaccess.HibernateSessionUtil.<clinit>(Unknown Source)
at com.sas.edu.educentral.edusa.data.DiscountProgramData.buildDiscountProgramList(Unknown Source)
at com.sas.edu.educentral.edusa.data.DiscountProgramData.getDiscountPrograms(Unknown Source)
at com.sas.edu.educentral.edusa.domain.DiscountProgramManager.getDiscountProgramList(Unknown Source)
at com.sas.edu.educentral.edusa.servlets.admin.DiscountProgramEditor.loadDiscountProgramEditor(Unknown Source)
at com.sas.edu.educentral.edusa.servlets.admin.DiscountProgramEditor.doGet(Unknown Source)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:526)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:306)
at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:385)
at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:745)
at org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:675)
at org.apache.jk.common.SocketConnection.runIt(ChannelSocket.java:868)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Unknown Source)
11:06:36,941 ERROR StandardWrapper[/EduCentral:AddUpdateDiscountProgram]:269 - Servlet.service() for servlet AddUpdateDiscountProgram threw exception
java.lang.NoClassDefFoundError
at com.sas.edu.educentral.edusa.data.DiscountProgramData.buildDiscountProgramList(Unknown Source)
at com.sas.edu.educentral.edusa.data.DiscountProgramData.getDiscountPrograms(Unknown Source)
at com.sas.edu.educentral.edusa.domain.DiscountProgramManager.getDiscountProgramList(Unknown Source)
at com.sas.edu.educentral.edusa.servlets.admin.DiscountProgramEditor.loadDiscountProgramEditor(Unknown Source)
at com.sas.edu.educentral.edusa.servlets.admin.DiscountProgramEditor.doGet(Unknown Source)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:526)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:306)
at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:385)
at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:745)
at org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:675)
at org.apache.jk.common.SocketConnection.runIt(ChannelSocket.java:868)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Unknown Source)
Code Generating the Exception:
/**
* Returns a list of all DiscountProgram records.
* @author ryalbe
* @return List of all Discount program records
* @throws DataReadException
*/
public List getDiscountPrograms() throws DataReadException {
return buildDiscountProgramList( "from DiscountProgram" );
}
/**
* Returns a list of the DiscountPrograms in the system data, or an empty list if no records are
* read.
* @author ryalbe
* @param none
* @return a list of the DiscountPrograms in the system data.
*/
public List buildDiscountProgramList( String selectString ) throws DataReadException {
Session session = null; // Hibernate session used to read the data
List discountProgramList = null; // list of DiscountProgram objects
// get a connection and add the record to the db
try {
session = HibernateSessionUtil.getSession(); // get a session for this thread
discountProgramList = session.find(selectString);
}
catch( HibernateException he ) {
throw new DataReadException( "Discount Program read failure: " + he.toString() );
}
catch( ConnectionException ce ) {
throw new DataReadException( "No data read: " + ce.toString() ); // throw exception indicating no data was read
}
finally {
try { HibernateSessionUtil.closeSession(); }
catch( ConnectionException ce ) { /* do nothing */ }
}
return discountProgramList;
}
I am using the HibernateUtils implementation found in Chapter 8 of Hibernate In Action.
Thanks.