Created
November 30, 2011 14:34
-
-
Save sebersole/1409264 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
try { | |
try { | |
PreparedStatement st = session.getTransactionCoordinator().getJdbcCoordinator().getStatementPreparer().prepareStatement( sql ); | |
try { | |
getLockable().getIdentifierType().nullSafeSet( st, id, 1, session ); | |
if ( getLockable().isVersioned() ) { | |
getLockable().getVersionType().nullSafeSet( | |
st, | |
version, | |
getLockable().getIdentifierType().getColumnSpan( factory ) + 1, | |
session | |
); | |
} | |
ResultSet rs = st.executeQuery(); | |
try { | |
if ( !rs.next() ) { | |
if ( factory.getStatistics().isStatisticsEnabled() ) { | |
factory.getStatisticsImplementor() | |
.optimisticFailure( getLockable().getEntityName() ); | |
} | |
throw new StaleObjectStateException( getLockable().getEntityName(), id ); | |
} | |
} | |
finally { | |
rs.close(); | |
} | |
} | |
finally { | |
st.close(); | |
} | |
} | |
catch ( SQLException sqle ) { | |
throw session.getFactory().getSQLExceptionHelper().convert( | |
sqle, | |
"could not lock: " + MessageHelper.infoString( getLockable(), id, session.getFactory() ), | |
sql | |
); | |
} | |
} | |
catch (PessimisticLockException pe) { | |
throw pe; | |
} | |
catch (JDBCException e) { | |
throw new PessimisticLockException( "could not obtain pessimistic lock", e, object ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment