HHH-6736 - Support for SELECT ... FOR UPDATE SKIP LOCKED / read past locking
This commit is contained in:
parent
e0cfc6bf2e
commit
4e126dcffc
|
@ -25,6 +25,8 @@ package org.hibernate.event.internal;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
import org.jboss.logging.Logger;
|
||||||
|
|
||||||
import org.hibernate.HibernateException;
|
import org.hibernate.HibernateException;
|
||||||
import org.hibernate.LockMode;
|
import org.hibernate.LockMode;
|
||||||
import org.hibernate.TransientObjectException;
|
import org.hibernate.TransientObjectException;
|
||||||
|
@ -36,6 +38,7 @@ import org.hibernate.engine.spi.SessionImplementor;
|
||||||
import org.hibernate.event.spi.EventSource;
|
import org.hibernate.event.spi.EventSource;
|
||||||
import org.hibernate.event.spi.LockEvent;
|
import org.hibernate.event.spi.LockEvent;
|
||||||
import org.hibernate.event.spi.LockEventListener;
|
import org.hibernate.event.spi.LockEventListener;
|
||||||
|
import org.hibernate.internal.CoreMessageLogger;
|
||||||
import org.hibernate.persister.entity.EntityPersister;
|
import org.hibernate.persister.entity.EntityPersister;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -46,7 +49,13 @@ import org.hibernate.persister.entity.EntityPersister;
|
||||||
*/
|
*/
|
||||||
public class DefaultLockEventListener extends AbstractLockUpgradeEventListener implements LockEventListener {
|
public class DefaultLockEventListener extends AbstractLockUpgradeEventListener implements LockEventListener {
|
||||||
|
|
||||||
/** Handle the given lock event.
|
private static final CoreMessageLogger LOG = Logger.getMessageLogger(
|
||||||
|
CoreMessageLogger.class,
|
||||||
|
DefaultLockEventListener.class.getName()
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle the given lock event.
|
||||||
*
|
*
|
||||||
* @param event The lock event to be handled.
|
* @param event The lock event to be handled.
|
||||||
* @throws HibernateException
|
* @throws HibernateException
|
||||||
|
@ -61,6 +70,10 @@ public class DefaultLockEventListener extends AbstractLockUpgradeEventListener i
|
||||||
throw new HibernateException( "Invalid lock mode for lock()" );
|
throw new HibernateException( "Invalid lock mode for lock()" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( event.getLockMode() == LockMode.UPGRADE_SKIPLOCKED ) {
|
||||||
|
LOG.explicitSkipLockedLockCombo();
|
||||||
|
}
|
||||||
|
|
||||||
SessionImplementor source = event.getSession();
|
SessionImplementor source = event.getSession();
|
||||||
|
|
||||||
Object entity = source.getPersistenceContext().unproxyAndReassociate( event.getObject() );
|
Object entity = source.getPersistenceContext().unproxyAndReassociate( event.getObject() );
|
||||||
|
|
|
@ -1609,4 +1609,11 @@ public interface CoreMessageLogger extends BasicLogger {
|
||||||
)
|
)
|
||||||
void embedXmlAttributesNoLongerSupported();
|
void embedXmlAttributesNoLongerSupported();
|
||||||
|
|
||||||
|
@LogMessage(level = WARN)
|
||||||
|
@Message(
|
||||||
|
value = "Explicit use of UPGRADE_SKIPLOCKED in lock() calls is not recommended; use normal UPGRADE locking instead",
|
||||||
|
id = 447
|
||||||
|
)
|
||||||
|
void explicitSkipLockedLockCombo();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,27 @@
|
||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
|
<!--
|
||||||
|
~ Hibernate, Relational Persistence for Idiomatic Java
|
||||||
|
~
|
||||||
|
~ Copyright (c) 2013, Red Hat Inc. or third-party contributors as
|
||||||
|
~ indicated by the @author tags or express copyright attribution
|
||||||
|
~ statements applied by the authors. All third-party contributions are
|
||||||
|
~ distributed under license by Red Hat Inc.
|
||||||
|
~
|
||||||
|
~ This copyrighted material is made available to anyone wishing to use, modify,
|
||||||
|
~ copy, or redistribute it subject to the terms and conditions of the GNU
|
||||||
|
~ Lesser General Public License, as published by the Free Software Foundation.
|
||||||
|
~
|
||||||
|
~ This program is distributed in the hope that it will be useful,
|
||||||
|
~ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
|
~ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||||
|
~ for more details.
|
||||||
|
~
|
||||||
|
~ You should have received a copy of the GNU Lesser General Public License
|
||||||
|
~ along with this distribution; if not, write to:
|
||||||
|
~ Free Software Foundation, Inc.
|
||||||
|
~ 51 Franklin Street, Fifth Floor
|
||||||
|
~ Boston, MA 02110-1301 USA
|
||||||
|
-->
|
||||||
<!DOCTYPE hibernate-mapping PUBLIC
|
<!DOCTYPE hibernate-mapping PUBLIC
|
||||||
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
|
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
|
||||||
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
|
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
/*
|
/*
|
||||||
* Hibernate, Relational Persistence for Idiomatic Java
|
* Hibernate, Relational Persistence for Idiomatic Java
|
||||||
*
|
*
|
||||||
* Copyright (c) 2012, Red Hat Inc. or third-party contributors as
|
* Copyright (c) 2013, Red Hat Inc. or third-party contributors as
|
||||||
* indicated by the @author tags or express copyright attribution
|
* indicated by the @author tags or express copyright attribution
|
||||||
* statements applied by the authors. All third-party contributions are
|
* statements applied by the authors. All third-party contributions are
|
||||||
* distributed under license by Red Hat Inc.
|
* distributed under license by Red Hat Inc.
|
||||||
|
|
Loading…
Reference in New Issue