Hibernate ORM LockEvent - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Hibernate ORM LockEvent class.

This code example shows how to use the following methods: getEntityName, getLockMode, getLockOptions, getObject, getSession
	 * @param event The lock event to be handled. 
	 * @throws HibernateException 
	 */ 
	public void onLock(LockEvent event) throws HibernateException {
 
		if ( event.getObject() == null ) {
			throw new NullPointerException( "attempted to lock null" );
		} 
 
		if ( event.getLockMode() == LockMode.WRITE ) {
			throw new HibernateException( "Invalid lock mode for lock()" );
		} 
 
		SessionImplementor source = event.getSession();
		 
		Object entity = source.getPersistenceContext().unproxyAndReassociate( event.getObject() );
		//TODO: if object was an uninitialized proxy, this is inefficient, 
		//      resulting in two SQL selects 
		 
		EntityEntry entry = source.getPersistenceContext().getEntry(entity);

7
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE