Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

StaleObjectStateException when transactions are removed

 
Jehan Jaleel
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I have some code that seems to be breaking when transactions are removed from it. Basically I am getting an object, changing some values in it, and then trying to re-save it. This code works fine if it is wrapped in a transaction but does not if it is not. Here it is...



Right now this code throws the following exception..



But if I put this code within a transaction then it works fine. Something like the following then it works ..



Does anyone know what is wrong How can I make this work without a transaction? I also attached my hbm file for that object.

Thanks so much for any help.


<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!--
Mapping file autogenerated by MyEclipse - Hibernate Tools
-->
<hibernate-mapping>
<class name="com.hfa.songreq.domain.SongRequestPubSplit" table="SONG_REQUEST_PUB_SPLIT" lazy="false">
<id name="songRequestPubSplitId" type="java.lang.Integer">
<column name="SONG_REQUEST_PUB_SPLIT_ID" />
<generator class="sequence"> <param name="sequence">seq_song_request_pub_split_id</param> </generator>
</id>
<timestamp name="updateTsp" column="UPDATE_TSP" unsaved-value="null" />
<property name="splitType" type="java.lang.Integer">
<column name="SPLIT_TYPE_ID" not-null="true" />
</property>
<many-to-one name="songRequest" class="com.hfa.songreq.domain.SongRequest" fetch="select">
<column name="SONG_REQUEST_ID" not-null="true" />
</many-to-one>
<property name="pubSplitStatusType" type="java.lang.Integer">
<column name="PUB_SPLIT_STATUS_TYPE_ID" not-null="true" />
</property>
<property name="collectionSharePct" type="java.lang.Double">
<column name="COLLECTION_SHARE_PCT" precision="6" scale="4" not-null="true" />
</property>
<property name="ownershipSharePct" type="java.lang.Double">
<column name="OWNERSHIP_SHARE_PCT" precision="6" scale="4" not-null="false" />
</property>
<property name="otherPubInd" type="java.lang.Integer">
<column name="OTHER_PUB_IND" not-null="true" />
</property>
<property name="copyrightControlInd" type="java.lang.Integer">
<column name="COPYRIGHT_CONTROL_IND" not-null="true" />
</property>
<property name="relHfaPubNum" type="java.lang.String">
<column name="REL_HFA_PUB_NUM" length="20" />
</property>
<set name="pubSuggestedMatchs" inverse="true" cascade="all,delete-orphan" lazy="false">
<key>
<column name="SONG_REQUEST_PUB_SPLIT_ID" />
</key>
<one-to-many class="com.hfa.songreq.domain.PubSuggestedMatch" />
</set>
<set name="songRequestPubs" inverse="true" cascade="all,delete-orphan" lazy="false">
<key>
<column name="SONG_REQUEST_PUB_SPLIT_ID" not-null="true" />
</key>
<one-to-many class="com.hfa.songreq.domain.SongRequestPub" />
</set>
<set name="songRequestPubTerritories" inverse="true" cascade="all,delete-orphan" lazy="false">
<key>
<column name="SONG_REQUEST_PUB_SPLIT_ID" not-null="true" />
</key>
<one-to-many class="com.hfa.songreq.domain.SongRequestPubTerritory" />
</set>
</class>
<query name="songRequestPubSplit.getById">
<![CDATA[
select srps
from SongRequestPubSplit srps, QueueSongRequestLookup qLookup, SongRequest sr
where srps.songRequest.songRequestId = qLookup.songRequest.songRequestId
and srps.pubSplitStatusType in (1, 2)
and srps.otherPubInd = 0
and qLookup.queue.queueId = ?
and qLookup.songRequest.songRequestId = sr.songRequestId
and sr.songRequestStatusType not in (0, 1, 2)
and sr.interfaceStatusType not in (4,5)
order by srps.splitType, srps.songRequestPubSplitId
]]>
</query>

<query name="songRequestPubSplit.getByQueueAndIntParty">
<![CDATA[
select distinct srps
from SongRequestPubSplit srps
join srps.songRequestPubs srp
join srps.songRequest.queueSongRequestLookups qsrl
where qsrl.queue.queueId = ?
and srp.pubIpNum = ?
and srp.parentPubIpNum = ?
and srps.otherPubInd = 0
]]>
</query>

<query name="songRequestPubSplit.findSongRequestPubSplitByCountryCode">
<![CDATA[
select srps
from SongRequestPubSplit srps
where
srps.songRequest.songRequestId=?
and
srps.songRequestPubSplitId
in
(select
srpt.songRequestPubSplit.songRequestPubSplitId from
SongRequestPubTerritory srpt
where srpt.countryCode = ?)
]]>
</query>


<sql-query name="unprocessedPubSplitsBySenderCAEAndIPNumbers">
<return-scalar column="pubSplitId" type="int"/>
SELECT
srps."SONG_REQUEST_PUB_SPLIT_ID" as pubSplitId
FROM
SONGREQ."SONG_REQUEST_PUB" srp,
SONGREQ."SONG_REQUEST_PUB_SPLIT" srps,
SONGREQ."QUEUE" q,
SONGREQ."QUEUE_SONG_REQUEST_LOOKUP" qsrl
WHERE
q."QUEUE_ID" = qsrl."QUEUE_ID"
and qsrl."SONG_REQUEST_ID" = srps."SONG_REQUEST_ID"
and srp."SONG_REQUEST_PUB_SPLIT_ID" = srps."SONG_REQUEST_PUB_SPLIT_ID"
and srps."OTHER_PUB_IND" = 0
and srps."PUB_SPLIT_STATUS_TYPE_ID" in (0, 1, 2)
and srp."PARENT_PUB_IP_NUM" = :parentIPNum
and srp."PUB_IP_NUM" = :ipNum
and q."SENDER_CAE" = :senderCAE
</sql-query>


<sql-query name="unprocessedPubSplitsByQueueIdAndIPNumbers">
<return-scalar column="pubSplitId" type="int"/>
SELECT
srps."SONG_REQUEST_PUB_SPLIT_ID" as pubSplitId
FROM
SONGREQ."SONG_REQUEST_PUB" srp,
SONGREQ."SONG_REQUEST_PUB_SPLIT" srps,
SONGREQ."QUEUE" q,
SONGREQ."QUEUE_SONG_REQUEST_LOOKUP" qsrl
WHERE
q."QUEUE_ID" = :queueId
and q."QUEUE_ID" = qsrl."QUEUE_ID"
and qsrl."SONG_REQUEST_ID" = srps."SONG_REQUEST_ID"
and srp."SONG_REQUEST_PUB_SPLIT_ID" = srps."SONG_REQUEST_PUB_SPLIT_ID"
and srps."OTHER_PUB_IND" = 0
and srps."PUB_SPLIT_STATUS_TYPE_ID" in (0, 1, 2)
and srp."PARENT_PUB_IP_NUM" = wnerIPNum
and srp."PUB_IP_NUM" = :adminIPNum
</sql-query>

<sql-query name="songsAssociatedWithSenderCAEAndIPNumbersForAQueue">
<return-scalar column="songRequestId" type="int"/>
<return-scalar column="submitterWorkId" type="string"/>
<return-scalar column="songTitle" type="string"/>
SELECT
distinct
sr."SONG_REQUEST_ID" as songRequestId,
sr."SUBMITTER_WORK_NUMBER" as submitterWorkId,
srt."TITLE_TXT" as songTitle
FROM
SONGREQ."SONG_REQUEST_PUB" srp,
SONGREQ."SONG_REQUEST_PUB_SPLIT" srps,
SONGREQ."QUEUE" q,
SONGREQ."QUEUE_SONG_REQUEST_LOOKUP" qsrl,
SONGREQ."SONG_REQUEST" sr,
SONGREQ."SONG_REQUEST_TITLE" srt
WHERE
q."QUEUE_ID" = qsrl."QUEUE_ID"
and qsrl."SONG_REQUEST_ID" = srps."SONG_REQUEST_ID"
and srp."SONG_REQUEST_PUB_SPLIT_ID" = srps."SONG_REQUEST_PUB_SPLIT_ID"
and srps."OTHER_PUB_IND" = 0
and srps."PUB_SPLIT_STATUS_TYPE_ID" in (0, 1, 2)
and qsrl."SONG_REQUEST_ID" = sr."SONG_REQUEST_ID"
and srt."SONG_REQUEST_ID" = sr."SONG_REQUEST_ID"
and srt."TITLE_TYPE_ID" = 4
and srp."PARENT_PUB_IP_NUM" = :parentIPNum
and srp."PUB_IP_NUM" = :ipNum
and q."SENDER_CAE" = :senderCAE
and q."QUEUE_ID" = :queueId
order by sr."SONG_REQUEST_ID"
</sql-query>

<sql-query name="getSongInfoByIPNumbers">
<return-scalar column="songRequestId" type="int"/>
<return-scalar column="submitterWorkId" type="string"/>
<return-scalar column="songTitle" type="string"/>
SELECT
distinct
sr."SONG_REQUEST_ID" as songRequestId,
sr."SUBMITTER_WORK_NUMBER" as submitterWorkId,
srt."TITLE_TXT" as songTitle
FROM
SONGREQ."SONG_REQUEST_PUB" srp,
SONGREQ."SONG_REQUEST_PUB_SPLIT" srps,
SONGREQ."QUEUE" q,
SONGREQ."QUEUE_SONG_REQUEST_LOOKUP" qsrl,
SONGREQ."SONG_REQUEST" sr,
SONGREQ."SONG_REQUEST_TITLE" srt
WHERE
q."QUEUE_ID" = qsrl."QUEUE_ID"
and qsrl."SONG_REQUEST_ID" = srps."SONG_REQUEST_ID"
and srp."SONG_REQUEST_PUB_SPLIT_ID" = srps."SONG_REQUEST_PUB_SPLIT_ID"
and srps."OTHER_PUB_IND" = 0
and srps."PUB_SPLIT_STATUS_TYPE_ID" in (0, 1, 2)
and qsrl."SONG_REQUEST_ID" = sr."SONG_REQUEST_ID"
and srt."SONG_REQUEST_ID" = sr."SONG_REQUEST_ID"
and srt."TITLE_TYPE_ID" = 4
and srp."PARENT_PUB_IP_NUM" = wnerIPNum
and srp."PUB_IP_NUM" = :adminIPNum
and q."QUEUE_ID" = :queueId
order by sr."SONG_REQUEST_ID"
</sql-query>


<sql-query name="songsAssociatedWithSenderCAEAndIPNumbers">
<return-scalar column="songRequestId" type="int"/>
<return-scalar column="submitterWorkId" type="string"/>
<return-scalar column="songTitle" type="string"/>
SELECT
distinct
sr."SONG_REQUEST_ID" as songRequestId,
sr."SUBMITTER_WORK_NUMBER" as submitterWorkId,
srt."TITLE_TXT" as songTitle
FROM
SONGREQ."SONG_REQUEST_PUB" srp,
SONGREQ."SONG_REQUEST_PUB_SPLIT" srps,
SONGREQ."QUEUE" q,
SONGREQ."QUEUE_SONG_REQUEST_LOOKUP" qsrl,
SONGREQ."SONG_REQUEST" sr,
SONGREQ."SONG_REQUEST_TITLE" srt
WHERE
q."QUEUE_ID" = qsrl."QUEUE_ID"
and qsrl."SONG_REQUEST_ID" = srps."SONG_REQUEST_ID"
and srp."SONG_REQUEST_PUB_SPLIT_ID" = srps."SONG_REQUEST_PUB_SPLIT_ID"
and srps."OTHER_PUB_IND" = 0
and srps."PUB_SPLIT_STATUS_TYPE_ID" in (0, 1, 2)
and qsrl."SONG_REQUEST_ID" = sr."SONG_REQUEST_ID"
and srt."SONG_REQUEST_ID" = sr."SONG_REQUEST_ID"
and srt."TITLE_TYPE_ID" = 4
and srp."PARENT_PUB_IP_NUM" = :parentIPNum
and srp."PUB_IP_NUM" = :ipNum
and q."SENDER_CAE" = :senderCAE
order by sr."SONG_REQUEST_ID"
</sql-query>
<sql-query name="linkedUnmatchedPubSplit">
<return-scalar column="pubSplitId" type="int"/>
SELECT
srp."SONG_REQUEST_PUB_SPLIT_ID" as pubSplitId
FROM
SONGREQ."SONG_REQUEST_PUB" srp,
SONGREQ."SONG_REQUEST_PUB_SPLIT" srps,
SONGREQ."QUEUE_SONG_REQUEST_LOOKUP" qsrl
WHERE
srp."SONG_REQUEST_PUB_SPLIT_ID" = srps."SONG_REQUEST_PUB_SPLIT_ID"
and srps."PUB_SPLIT_STATUS_TYPE_ID" = 2
and srp."PUB_IP_NUM" = :ipNum
and srp."PARENT_PUB_IP_NUM" = :parentIPNum
and srps."SONG_REQUEST_ID" = qsrl."SONG_REQUEST_ID"
and qsrl."QUEUE_ID" = :queueId
</sql-query>
</hibernate-mapping>

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic