-->
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.  [ 5 posts ] 
Author Message
 Post subject: DB2 OS/390 indentity returns 0 always
PostPosted: Wed Jul 30, 2008 1:19 pm 
Newbie

Joined: Wed Jul 30, 2008 12:57 pm
Posts: 3
Thanks in andvance for any help.

We are inserting rows into DB2. We use JBoss and Spring. When we insert these rows and then ask for the identity number ont DB2/NT everything works fine. When we use DB2 OS/390 we get the error listed below. As if the identity is alway returning null or 0.

This is on one of our customer's machines so I'm waiting on more logging.

Again, this works fine on DB2/NT, Oracle, Sql Server, etc. Problem only happens on OS/390.

The DB2390Dialect has been around for years, so it must be something with our configuration. Is there anything special that needs to be done?

Thanks again...

Hibernate version:3.2.6

Mapping documents:<hibernate-mapping>
<!--
Created by the Middlegen Hibernate plugin

http://boss.bekk.no/boss/middlegen/
http://hibernate.sourceforge.net/
-->
<class
name="dars.apis.audit.JobQueueSysin"
table="job_queue_sysin"
lazy="false"
>
<meta attribute="pre-class-code">@SuppressWarnings("serial")</meta>

<meta attribute="generated-class" inherit="false">dars.apis.audit.BaseJobQueueSysin</meta>

<id
name="intSeqNo"
type="java.lang.Integer"
column="int_seq_no"
>
<meta attribute="use-in-tostring">true</meta>
<meta attribute="use-in-equals">true</meta>
<meta attribute="use-in-equals">true</meta>
<generator class="native">
<param name="sequence">jobqsi_seq_no</param>
</generator>

</id>
.
.
.


Code between sessionFactory.openSession() and session.close():Just getHibernateTemplate().save(object); //Spring

Full stack trace of any exception that occurs:org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session: [dars.apis.audit.JobQueueSysin#0]
at org.hibernate.engine.StatefulPersistenceContext.checkUniqueness(StatefulPersistenceContext.java:590)
at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:303)
at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:181)
at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:107)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:187)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:172)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:94)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
at org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:507)
at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:499)
at org.hibernate.engine.CascadingAction$5.cascade(CascadingAction.java:218)
at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:268)
at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:216)
at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169)
at org.hibernate.engine.Cascade.cascadeCollectionElements(Cascade.java:296)
at org.hibernate.engine.Cascade.cascadeCollection(Cascade.java:242)
at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:219)
at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169)
at org.hibernate.engine.Cascade.cascade(Cascade.java:130)
at org.hibernate.event.def.AbstractSaveEventListener.cascadeAfterSave(AbstractSaveEventListener.java:456)
at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:334)
at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:181)
at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:121)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:187)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:172)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:94)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
at org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:507)
at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:499)
at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:495)
at org.springframework.orm.hibernate3.HibernateTemplate$16.doInHibernate(HibernateTemplate.java:702)
at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:374)
... 45 more

Name and version of the database you are using:DB2 OS/390

The generated SQL (show_sql=true):
2008-07-28 09:34:12,956 DEBUG [org.hibernate.SQL] select jobqueueli_.instidq, jobqueueli_.instid, jobqueueli_.instcd, jobqueueli_.jobid, jobqueueli_.userid, jobqueueli_.status as status2_, jobqueueli_.priority as priority2_, jobqueueli_.startdate as startdate2_, jobqueueli_.starttime as starttime2_, jobqueueli_.external_eval as external10_2_, jobqueueli_.read_sysin as read11_2_, jobqueueli_.servername as servername2_, jobqueueli_.last_mod_user as last13_2_, jobqueueli_.last_mod_date as last14_2_ from job_queue_list jobqueueli_ where jobqueueli_.instidq=? and jobqueueli_.instid=? and jobqueueli_.instcd=? and jobqueueli_.jobid=? and jobqueueli_.userid=?
2008-07-28 09:34:13,418 DEBUG [org.hibernate.SQL] select jobqueueli0_.instidq as instidq2_, jobqueueli0_.instid as instid2_, jobqueueli0_.instcd as instcd2_, jobqueueli0_.jobid as jobid2_, jobqueueli0_.userid as userid2_, jobqueueli0_.status as status2_, jobqueueli0_.priority as priority2_, jobqueueli0_.startdate as startdate2_, jobqueueli0_.starttime as starttime2_, jobqueueli0_.external_eval as external10_2_, jobqueueli0_.read_sysin as read11_2_, jobqueueli0_.servername as servername2_, jobqueueli0_.last_mod_user as last13_2_, jobqueueli0_.last_mod_date as last14_2_ from job_queue_list jobqueueli0_ where jobqueueli0_.servername=? and (userid like ?) and (jobqueueli0_.status in ('D' , 'E'))
2008-07-28 09:34:16,119 DEBUG [org.hibernate.SQL] insert into job_queue_list (status, priority, startdate, starttime, external_eval, read_sysin, servername, last_mod_user, last_mod_date, instidq, instid, instcd, jobid, userid) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
2008-07-28 09:34:18,095 DEBUG [org.hibernate.SQL] insert into job_queue_sysin (int_seq_no, user_seq_no, sysin, instidq, instid, instcd, jobid, userid) values (default, ?, ?, ?, ?, ?, ?, ?)
2008-07-28 09:34:18,406 DEBUG [org.hibernate.SQL] select jobqueueli0_.instidq as instidq2_, jobqueueli0_.instid as instid2_, jobqueueli0_.instcd as instcd2_, jobqueueli0_.jobid as jobid2_, jobqueueli0_.userid as userid2_, jobqueueli0_.status as status2_, jobqueueli0_.priority as priority2_, jobqueueli0_.startdate as startdate2_, jobqueueli0_.starttime as starttime2_, jobqueueli0_.external_eval as external10_2_, jobqueueli0_.read_sysin as read11_2_, jobqueueli0_.servername as servername2_, jobqueueli0_.last_mod_user as last13_2_, jobqueueli0_.last_mod_date as last14_2_ from job_queue_list jobqueueli0_ where jobqueueli0_.servername=? and (userid like ?) and (jobqueueli0_.status in ('D' , 'E'))
2008-07-28 09:34:18,781 DEBUG [org.hibernate.SQL] select identity_val_local() from sysibm.sysdummy1
2008-07-28 09:34:18,801 DEBUG [org.hibernate.SQL] insert into job_queue_sysin (int_seq_no, user_seq_no, sysin, instidq, instid, instcd, jobid, userid) values (default, ?, ?, ?, ?, ?, ?, ?)
2008-07-28 09:34:18,828 DEBUG [org.hibernate.SQL] select identity_val_local() from sysibm.sysdummy1



Debug level Hibernate log excerpt:


Problems with Session and transaction handling? Maybe?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 31, 2008 4:21 pm 
Expert
Expert

Joined: Tue May 13, 2008 3:42 pm
Posts: 919
Location: Toronto & Ajax Ontario www.hibernatemadeeasy.com
The change to the 390, does this involve any architecture change as well, perhaps even a workload manage/load balanced HttpSession implementation?

Sometimes I see this when HttpSessions are used, especially in a cluster. You pull an object from the Hibernate Session, you put it in an HttpSession, then you pull it out of the HttpSession a bit later, but Hibernate thinks it's a DIFFERENT POJO, not the same one you put into the HttpSession. So, it then tries to do an insert or update, and it complains that you have two POJOs with a common ID, when really you don't.

Sometimes overriding .eqauls and .hashcode can help avoid this, but not always.

I've got a tutorial on How Hibernate Works that goes into this a little bit. Not sure if it solves your problem, but it might be an interesting read:

http://www.hiberbook.com/HiberBookWeb/learn.jsp?tutorial=07howhibernateworks

_________________
Cameron McKenzie - Author of "Hibernate Made Easy" and "What is WebSphere?"
http://www.TheBookOnHibernate.com Check out my 'easy to follow' Hibernate & JPA Tutorials


Top
 Profile  
 
 Post subject: Thanks, but that's not the problem
PostPosted: Fri Aug 01, 2008 7:14 am 
Newbie

Joined: Wed Jul 30, 2008 12:57 pm
Posts: 3
We've done more and more research, it has to do with that database's behavior.

You can't get the identity back after the insert if there was a commit.

It may be that auto commit is not set to false, or it needs to be within a transaction. We're trying different things...


Top
 Profile  
 
 Post subject: Success
PostPosted: Fri Aug 01, 2008 10:58 am 
Newbie

Joined: Wed Jul 30, 2008 12:57 pm
Posts: 3
This is working. The access to DB2 OS/390 has to be done within a Transaction.

For me this meant using AOP in spring to do some tx wrapping.

But without the transaction OS/390 would always return "0".

This worked without an explicit transaction in all other versions of DB2.


Top
 Profile  
 
 Post subject: Re: DB2 OS/390 indentity returns 0 always
PostPosted: Tue Oct 13, 2009 4:51 pm 
Newbie

Joined: Tue Oct 13, 2009 12:00 pm
Posts: 5
I know this is old.. but I ran into the same prob... you have a solution?


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