-->
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.  [ 3 posts ] 
Author Message
 Post subject: Newbie ID Generator problem
PostPosted: Thu Jul 21, 2005 10:46 am 
Beginner
Beginner

Joined: Thu Jul 21, 2005 10:28 am
Posts: 21
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: 2.0.x

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.starwood.saratoga.dataaccess.dvo.AgentMessageDVO"
table="CCC.AGNT_MSG">

<id name="messageId" type="java.lang.Long" unsaved-value="0" column="MSG_ID">
<generator class="sequence">
<param name="sequence">CCC.SEQ.AGNT_MSG</param>
</generator>
</id>

<!--
<set name="recipients" cascade="all">
<key column="MSG_ID" />
<one-to-many class="com.starwood.saratoga.dataaccess.dvo.MessageRecipientDVO" />
</set>
-->

<!--
<property name="messageId" type="long" insert="false" update="false" >
<column name="MSG_ID" sql-type="NUMBER" not-null="true"/>
</property>
-->

<property name="fromDate" type="date">
<column name="MSG_START_DATE" sql-type="DATE" not-null="false" />
</property>

<property name="toDate" type="date">
<column name="END_START_DATE" sql-type="DATE" not-null="false" />
</property>

<property name="messageText" type="string">
<column name="MSG_TEXT" sql-type="VARCHAR2(500)" not-null="false" />
</property>

<property name="categoryCode" type="string">
<column name="MSG_CATG_CD" sql-type="VARCHAR2(20)" not-null="false" />
</property>

<property name="behaviorCode" type="string">
<column name="MSG_BHVR_CD" sql-type="VARCHAR2(20)" not-null="false" />
</property>

<property name="createUser" type="string">
<column name="CREATE_USER" sql-type="VARCHAR2(20)"
not-null="false" />
</property>

<property name="createDate" type="date">
<column name="CREATE_DATE" sql-type="DATE" not-null="false" />
</property>

<property name="modUser" type="string">
<column name="MOD_USER" sql-type="VARCHAR2(20)"
not-null="false" />
</property>

<property name="modDate" type="date">
<column name="MOD_DATE" sql-type="DATE" not-null="false" />
</property>

<!--
<many-to-one name="messageCategoryDVO" column="MSG_CATG_CD" class="com.starwood.saratoga.dataaccess.dvo.MessageCategoryDVO" not-null="true" insert="false" update="false"/>
<many-to-one name="messageBehaviorDVO" column="MSG_BHVR_CD" class="com.starwood.saratoga.dataaccess.dvo.MessageBehaviorDVO" not-null="true" insert="false" update="false"/>
-->

</class>

<!--
<class
name="com.starwood.saratoga.dataaccess.dvo.MessageRecipientDVO"
table="CCC.MSG_RECIPIENT">

<composite-id name="compositeKey" class="com.starwood.saratoga.dataaccess.dao.MessageRecipientCompositeKey">
<key-property name="messageId" type="long" column="MSG_ID"/>
<key-property name="recipientId" type="string" column="RECIPIENT_ID"/>
<key-property name="receiverCategoryCode" type="string" column="RCVR_CATG_CD"/>
</composite-id>

<property name="messageId" type="long" insert="false" update="false" >
<column name="MSG_ID" sql-type="NUMBER" not-null="true"/>
</property>

<property name="recipientId" type="string" insert="false" update="false" >
<column name="RECIPIENT_ID" sql-type="VARCHAR2(50)" not-null="true"/>
</property>

<property name="receiverCategoryCode" type="string" insert="false" update="false" >
<column name="RCVR_CATG_CD" sql-type="VARCHAR2(20)" not-null="true"/>
</property>

<many-to-one name="receiverCategoryCodes" column="RCVR_CATG_CD" class="com.starwood.saratoga.dataaccess.dvo.ReceiverCategory" not-null="true" insert="false" update="false"/>

</class>
-->

</hibernate-mapping>


Code between sessionFactory.openSession() and session.close():

Session session = null;
try {
System.out.println("AgentMessageDAO: create Transaction");
Transaction tx = session.beginTransaction();
System.out.println("AgentMessageDAO: create session");
session = HibernateUtil.currentSession();
session.saveOrUpdate(agentMessageDVO);
tx.commit();
} catch (HibernateException e) {
log("AgentMessageDVO: saveOrUpdate: Hibernate Error Occured");
e.printStackTrace();
} finally {
try {
HibernateUtil.closeSession(session);
} catch (Exception ignore) {
log("AgentMessageDVO: saveOrUpdate: Session Close Error Occured");
ignore.printStackTrace();
}

Full stack trace of any exception that occurs:
[7/21/05 10:26:27:925 EDT] 29a716b5 SystemOut O HibernateUtil: creating Session factory: start
[7/21/05 10:26:27:925 EDT] 29a716b5 Configuration I net.sf.hibernate.cfg.Configuration configuring from url: file:/C:/workspace/saratoga/Common/classes/com/starwood/saratoga/dataaccess/Security.cfg.xml
[7/21/05 10:26:27:935 EDT] 29a716b5 Configuration I net.sf.hibernate.cfg.Configuration Mapping resource: com/starwood/saratoga/dataaccess/AgentMessage.hbm.xml
[7/21/05 10:26:27:945 EDT] 29a716b5 Binder I net.sf.hibernate.cfg.Binder Mapping class: com.starwood.saratoga.dataaccess.dvo.AgentMessageDVO -> CCC.AGNT_MSG
[7/21/05 10:26:27:945 EDT] 29a716b5 Configuration I net.sf.hibernate.cfg.Configuration Mapping resource: com/starwood/saratoga/dataaccess/MessageCategory.hbm.xml
[7/21/05 10:26:27:955 EDT] 29a716b5 Binder I net.sf.hibernate.cfg.Binder Mapping class: com.starwood.saratoga.dataaccess.dvo.MessageCategoryDVO -> CCC.MSG_CATG_LKUP
[7/21/05 10:26:27:955 EDT] 29a716b5 Configuration I net.sf.hibernate.cfg.Configuration Mapping resource: com/starwood/saratoga/dataaccess/MessageBehavior.hbm.xml
[7/21/05 10:26:27:965 EDT] 29a716b5 Binder I net.sf.hibernate.cfg.Binder Mapping class: com.starwood.saratoga.dataaccess.dvo.MessageBehaviorDVO -> CCC.MSG_BHVR_CD_LKUP
[7/21/05 10:26:27:965 EDT] 29a716b5 Configuration I net.sf.hibernate.cfg.Configuration Mapping resource: com/starwood/saratoga/dataaccess/ReceiverCategory.hbm.xml
[7/21/05 10:26:27:975 EDT] 29a716b5 Binder I net.sf.hibernate.cfg.Binder Mapping class: com.starwood.saratoga.dataaccess.dvo.ReceiverCategoryDVO -> CCC.RCVR_CATG_LKUP
[7/21/05 10:26:27:975 EDT] 29a716b5 Configuration I net.sf.hibernate.cfg.Configuration Configured SessionFactory: null
[7/21/05 10:26:27:985 EDT] 29a716b5 Configuration I net.sf.hibernate.cfg.Configuration processing one-to-many association mappings
[7/21/05 10:26:27:985 EDT] 29a716b5 Configuration I net.sf.hibernate.cfg.Configuration processing one-to-one association property references
[7/21/05 10:26:27:985 EDT] 29a716b5 Configuration I net.sf.hibernate.cfg.Configuration processing foreign key constraints
[7/21/05 10:26:27:985 EDT] 29a716b5 Dialect I net.sf.hibernate.dialect.Dialect Using dialect: net.sf.hibernate.dialect.OracleDialect
[7/21/05 10:26:27:985 EDT] 29a716b5 SettingsFacto I net.sf.hibernate.cfg.SettingsFactory Maximim outer join fetch depth: 0
[7/21/05 10:26:27:985 EDT] 29a716b5 SettingsFacto I net.sf.hibernate.cfg.SettingsFactory Use outer join fetching: true
[7/21/05 10:26:27:985 EDT] 29a716b5 NamingHelper I net.sf.hibernate.util.NamingHelper JNDI InitialContext properties:{}
[7/21/05 10:26:27:995 EDT] 29a716b5 DatasourceCon I net.sf.hibernate.connection.DatasourceConnectionProvider Using datasource: jdbc/OraDb
[7/21/05 10:26:27:995 EDT] 29a716b5 TransactionFa I net.sf.hibernate.transaction.TransactionFactoryFactory Transaction strategy: net.sf.hibernate.transaction.JDBCTransactionFactory
[7/21/05 10:26:27:995 EDT] 29a716b5 TransactionMa I net.sf.hibernate.transaction.TransactionManagerLookupFactory No TransactionManagerLookup configured (in JTA environment, use of process level read-write cache is not recommended)
[7/21/05 10:26:27:995 EDT] 29a716b5 SettingsFacto I net.sf.hibernate.cfg.SettingsFactory Use scrollable result sets: true
[7/21/05 10:26:27:995 EDT] 29a716b5 SettingsFacto I net.sf.hibernate.cfg.SettingsFactory Use JDBC3 getGeneratedKeys(): false
[7/21/05 10:26:27:995 EDT] 29a716b5 SettingsFacto I net.sf.hibernate.cfg.SettingsFactory Optimize cache for minimal puts: false
[7/21/05 10:26:27:995 EDT] 29a716b5 SettingsFacto I net.sf.hibernate.cfg.SettingsFactory Query language substitutions: {}
[7/21/05 10:26:27:995 EDT] 29a716b5 SettingsFacto I net.sf.hibernate.cfg.SettingsFactory cache provider: net.sf.ehcache.hibernate.Provider
[7/21/05 10:26:27:995 EDT] 29a716b5 Configuration I net.sf.hibernate.cfg.Configuration instantiating and configuring caches
[7/21/05 10:26:27:995 EDT] 29a716b5 SessionFactor I net.sf.hibernate.impl.SessionFactoryImpl building session factory
[7/21/05 10:26:28:005 EDT] 29a716b5 SystemErr R net.sf.hibernate.MappingException: could not instantiate id generator
at net.sf.hibernate.id.IdentifierGeneratorFactory.create(IdentifierGeneratorFactory.java:82)
at net.sf.hibernate.mapping.SimpleValue.createIdentifierGenerator(SimpleValue.java:82)
at net.sf.hibernate.persister.AbstractEntityPersister.<init>(AbstractEntityPersister.java:630)
at net.sf.hibernate.persister.EntityPersister.<init>(EntityPersister.java:714)
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:768)
at com.starwood.saratoga.dataaccess.HibernateUtil.<clinit>(HibernateUtil.java:15)
at com.starwood.saratoga.dataaccess.dao.AgentMessageDAO.saveOrUpdate(AgentMessageDAO.java:71)
at com.starwood.saratoga.struts.messages.edit.MessagesAddAction.execute(MessagesAddAction.java:162)
at com.ibm.wps.portlets.struts.WpsRequestProcessor.processActionPerform(WpsRequestProcessor.java:335)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
at com.ibm.wps.portlets.struts.WpsStrutsPortlet.processActionPerformed(WpsStrutsPortlet.java:1753)
at com.ibm.wps.portlets.struts.WpsStrutsPortlet.actionPerformed(WpsStrutsPortlet.java:1460)
at com.ibm.wps.pe.pc.legacy.SPIPortletInterceptorImpl.handleEvents(SPIPortletInterceptorImpl.java:360)
at com.ibm.wps.pe.pc.legacy.invoker.impl.PortletDelegateImpl._dispatch(PortletDelegateImpl.java(Compiled Code))
at com.ibm.wps.pe.pc.legacy.invoker.impl.PortletDelegateImpl.access$200(PortletDelegateImpl.java(Inlined Compiled Code))
at com.ibm.wps.pe.pc.legacy.invoker.impl.PortletDelegateImpl$Context.callPortlet(PortletDelegateImpl.java(Inlined Compiled Code))
at com.ibm.wps.pe.pc.legacy.services.PortletFilterServiceImpl.doFilter(PortletFilterServiceImpl.java(Compiled Code))
at com.ibm.wps.pe.pc.legacy.services.PortletFilter.doFilter(PortletFilter.java(Inlined Compiled Code))
at com.ibm.wps.pe.pc.legacy.invoker.impl.PortletDelegateImpl.dispatch(PortletDelegateImpl.java(Compiled Code))
at org.apache.jetspeed.portlet.Portlet.doPost(Portlet.java:512)
at javax.servlet.http.HttpServlet.service(HttpServlet.java(Compiled Code))
at com.ibm.wps.pe.pc.legacy.cache.CacheablePortlet.service(CacheablePortlet.java(Compiled Code))
at javax.servlet.http.HttpServlet.service(HttpServlet.java(Compiled Code))
at org.apache.jetspeed.portlet.Portlet.service(Portlet.java(Compiled Code))
at com.ibm.ws.webcontainer.servlet.StrictServletInstance.doService(StrictServletInstance.java(Compiled Code))
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet._service(StrictLifecycleServlet.java(Compiled Code))
at com.ibm.ws.webcontainer.servlet.IdleServletState.service(StrictLifecycleServlet.java(Compiled Code))
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet.service(StrictLifecycleServlet.java(Inlined Compiled Code))
at com.ibm.ws.webcontainer.servlet.ServletInstance.service(ServletInstance.java(Compiled Code))
at com.ibm.ws.webcontainer.servlet.ValidServletReferenceState.dispatch(ValidServletReferenceState.java(Compiled Code))
at com.ibm.ws.webcontainer.servlet.ServletInstanceReference.dispatch(ServletInstanceReference.java(Inlined Compiled Code))
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.handleWebAppDispatch(WebAppRequestDispatcher.java(Compiled Code))
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java(Compiled Code))
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.include(WebAppRequestDispatcher.java(Inlined Compiled Code))
at com.ibm.wps.pe.pc.legacy.invoker.impl.PortletInvokerImpl.callMethod(PortletInvokerImpl.java(Compiled Code))
at com.ibm.wps.pe.pc.legacy.invoker.impl.PortletInvokerImpl.action(PortletInvokerImpl.java:82)
at com.ibm.wps.pe.pc.legacy.PortletContainerImpl.callPortletMethod(PortletContainerImpl.java(Compiled Code))
at com.ibm.wps.pe.pc.legacy.EventEnvironmentImpl.includePortlet(EventEnvironmentImpl.java:177)
at com.ibm.wps.pe.pc.legacy.event.ActionEventImpl.prepare(ActionEventImpl.java:121)
at com.ibm.wps.pe.pc.legacy.event.EventQueueManager.processEventLoop(EventQueueManager.java:83)
at com.ibm.wps.pe.pc.legacy.PortletContainerImpl.performEventPhase(PortletContainerImpl.java(Compiled Code))
at com.ibm.wps.pe.pc.legacy.PortletContainerImpl.performEvents(PortletContainerImpl.java:210)
at com.ibm.wps.pe.pc.PortletContainerImpl.performEvents(PortletContainerImpl.java:212)
at com.ibm.wps.engine.phases.WPActionPhase.processPortlets(WPActionPhase.java:1170)
at com.ibm.wps.engine.phases.WPActionPhase.execute(WPActionPhase.java:561)
at com.ibm.wps.state.phases.AbstractActionPhase.next(AbstractActionPhase.java:130)
at com.ibm.wps.engine.Servlet.callPortal(Servlet.java:638)
at com.ibm.wps.engine.Servlet.doGet(Servlet.java:496)
at com.ibm.wps.engine.Servlet.doPost(Servlet.java:664)
at javax.servlet.http.HttpServlet.service(HttpServlet.java(Compiled Code))
at javax.servlet.http.HttpServlet.service(HttpServlet.java(Compiled Code))
at com.ibm.ws.webcontainer.servlet.StrictServletInstance.doService(StrictServletInstance.java(Compiled Code))
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet._service(StrictLifecycleServlet.java(Compiled Code))
at com.ibm.ws.webcontainer.servlet.IdleServletState.service(StrictLifecycleServlet.java(Compiled Code))
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet.service(StrictLifecycleServlet.java(Inlined Compiled Code))
at com.ibm.ws.webcontainer.servlet.ServletInstance.service(ServletInstance.java(Compiled Code))
at com.ibm.ws.webcontainer.servlet.ValidServletReferenceState.dispatch(ValidServletReferenceState.java(Compiled Code))
at com.ibm.ws.webcontainer.servlet.ServletInstanceReference.dispatch(ServletInstanceReference.java(Compiled Code))
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:76)
at com.ibm.wps.state.filter.StateCleanup.doFilter(StateCleanup.java:71)
at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:132)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:71)
at com.ibm.wps.mappingurl.impl.URLAnalyzer.doFilter(URLAnalyzer.java:174)
at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:132)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:71)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.handleWebAppDispatch(WebAppRequestDispatcher.java(Compiled Code))
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java(Compiled Code))
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:204)
at com.ibm.ws.webcontainer.srt.WebAppInvoker.doForward(WebAppInvoker.java:125)
at com.ibm.ws.webcontainer.srt.WebAppInvoker.handleInvocationHook(WebAppInvoker.java:286)
at com.ibm.ws.webcontainer.cache.invocation.CachedInvocation.handleInvocation(CachedInvocation.java:71)
at com.ibm.ws.webcontainer.srp.ServletRequestProcessor.dispatchByURI(ServletRequestProcessor.java:182)
at com.ibm.ws.webcontainer.oselistener.OSEListenerDispatcher.service(OSEListener.java:334)
at com.ibm.ws.webcontainer.http.HttpConnection.handleRequest(HttpConnection.java:56)
at com.ibm.ws.http.HttpConnection.readAndHandleRequest(HttpConnection.java:615)
at com.ibm.ws.http.HttpConnection.run(HttpConnection.java:439)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:912)
Caused by: java.lang.ClassNotFoundException:
at com.ibm.ws.classloader.CompoundClassLoader.findClass(CompoundClassLoader.java(Compiled Code))
at com.ibm.ws.classloader.CompoundClassLoader.loadClass(CompoundClassLoader.java(Compiled Code))
at java.lang.ClassLoader.loadClass(ClassLoader.java(Compiled Code))
at java.lang.Class.forName1(Native Method)
at java.lang.Class.forName(Class.java(Compiled Code))
at net.sf.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:102)
at net.sf.hibernate.id.IdentifierGeneratorFactory.create(IdentifierGeneratorFactory.java:76)
... 78 more

Name and version of the database you are using:
Oracle 9i

The generated SQL (show_sql=true): N/A at this time

Debug level Hibernate log excerpt:
Don't even know where to find this.

Ok, I am a newbie and I am just learning Hibernate. I've got the Wrox book on Hibernate and I plan on getting the Hibernate in Action book.

The problem is obvious. I am trying to write a single record to my single Oracle database table. There is a sequence, and I tested to make sure it works. I can manually enter information into this table.

The error is "could not instantiate id generator" and way down at the bottom is a ClassNotFoundException.

So .... I've added a ton of classes to my classpath that I thought were needed. No effect. Is this classpath exception because one of my VO files is wrong? I created them by hand the way the examples showed.

I've spent the last 3 days working on this problem, and spent 3 days surfing this site and the internet trying to find out how to solve this problem. I have tried changing the generator from sequence to native to assigned, and nothing works.

If you need more information, please let me know, but this is what I have and I hope someone here can help me. Thanks.

Tom


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 21, 2005 11:14 am 
Newbie

Joined: Sun Jul 17, 2005 1:48 am
Posts: 4
Tom,

I am also new at hibernate so I don't know if this is really your problem but I've noticed different behaviour among generators. try identity instead of sequence

Code:
<generator class="identity">
[/code]


Top
 Profile  
 
 Post subject: id code generation - solved for now
PostPosted: Thu Jul 21, 2005 2:26 pm 
Beginner
Beginner

Joined: Thu Jul 21, 2005 10:28 am
Posts: 21
I SOLVED THIS PROBLEM ... YEAH!

In the hibernate.cfg.cml file I had a few other resources that were linked to 3 other hbm.xml files. These three hbm.xml tables were just supposed to be lookups to other tables. They had and empty string defined as a generator <generator name="" /> and that was valid XML. However, it should have been at least <generator name="assigned" />

So ... it wasn't the problem with my original first hbm.xml, it was the other ones ....

Oh well ... I hope this solves problems for other people.


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