org.hibernate.StaleObjectStateException is thrown with simple parent child relationship

Description

Test case shown below:
https://github.com/jjangsam/HibernateExample

We have simple parent child relationship. Right -> RightTrialUserField.

According to hibernate log, update statement is excuted once. But StaleObjectStateException is thrown.

2619 [main] DEBUG org.hibernate.SQL -
update
RIGHT_TRIAL_USE_FIELDS
set
UPDATE_DATE=?,
ASSET_TYPE=?,
NAME=?,
VALUE_TYPE=?,
VALUE=?,
DESCRIPTION=?,
CREATED_BY=?,
UPDATED_BY=?,
CREATE_DATE=?,
MAPPING_ID=?,
RIGHT_ID=?
where
TRIAL_USE_FIELD_ID=?
and UPDATE_DATE=?

Also attaching DB sql script.

Environment

Oracle 11.2.0.3.0, ojdbc6 (11.2.0), javassist (3.6.0.GA)

Activity

Show:
Bryan Kim
September 15, 2014, 8:12 PM

Log got cut off:

2619 [main] DEBUG org.hibernate.SQL -
update
RIGHT_TRIAL_USE_FIELDS
set
UPDATE_DATE=?,
ASSET_TYPE=?,
NAME=?,
VALUE_TYPE=?,
VALUE=?,
DESCRIPTION=?,
CREATED_BY=?,
UPDATED_BY=?,
CREATE_DATE=?,
MAPPING_ID=?,
RIGHT_ID=?
where
TRIAL_USE_FIELD_ID=?
and UPDATE_DATE=?
Exception in thread "main" org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect): [com.plm.model.RightTrialUseFields#109]
at org.hibernate.persister.entity.AbstractEntityPersister.check(AbstractEntityPersister.java:2523)
at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:3242)
at org.hibernate.persister.entity.AbstractEntityPersister.updateOrInsert(AbstractEntityPersister.java:3140)
at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:3470)
at org.hibernate.action.internal.EntityUpdateAction.execute(EntityUpdateAction.java:140)
at org.hibernate.engine.spi.ActionQueue.execute(ActionQueue.java:393)
at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:385)
at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:302)
at org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:339)
at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:52)
at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1240)
at com.plm.App.main(App.java:73)

Steve Ebersole
October 27, 2015, 7:15 PM

This bug report does not indicate that the reported issue affects version 5.x. Versions prior to 5.x are no longer maintained. It would be a great help to the Hibernate team and community for someone to verify that the reported issue still affects version 5.x. If so, please add the 5.x version that you verified with to the list of affected-versions and attach the (preferably SSCCE) test case you used to do the verification to the report; from there the issues will be looked at during our triage meetings.

For details, see http://in.relation.to/2015/10/27/great-jira-cleanup-2015/

Steve Ebersole
October 28, 2015, 3:26 AM

As part of verifying that this issue affects 5.0, please just set the "Affects version". Leave the "verify-affects-5.0" label and leave the issue in "Awaiting Response" status; these are critical for us to be able to track these verifications and triage them. Thanks.

Christian Beikov
October 30, 2015, 8:30 AM

You are not mapping the timezone for the column so in the java model you always have a updateDate that has no timezone. Updating with the condition that the updateDate didn't change will fail then, because you are missing the timezone thus the update does not work. Optimistic locking logic then throws the exception.

Assignee

Unassigned

Reporter

Bryan Kim

Fix versions

None

Labels

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

Priority

Major
Configure