Code example for Session

Methods: load

0
	 
	public static void rethrowOptimisticLockException(Session session, StaleObjectStateException sose) {
		Serializable identifier = sose.getIdentifier();
		if (identifier != null) {
			try { 
				Object entity = session.load(sose.getEntityName(), identifier);
				if (entity instanceof Serializable) {
					//avoid some user errors regarding boundary crossing 
					throw new HibernateOptimisticLockException(null, sose, entity);
				} 
			} 
			catch (ObjectNotFoundException onfe) {
				// Ignored, StaleStateException will be rethrown 
			} 
		} 
	} 
}