Permalink
Browse files

HHH-6736 - Support for SELECT ... FOR UPDATE SKIP LOCKED / read past …

…locking
  • Loading branch information...
1 parent e0cfc6b commit 4e126dcffc8959c6754c2cfdffc969cf02977822 @sebersole sebersole committed Feb 20, 2013
@@ -25,6 +25,8 @@
import java.io.Serializable;
+import org.jboss.logging.Logger;
+
import org.hibernate.HibernateException;
import org.hibernate.LockMode;
import org.hibernate.TransientObjectException;
@@ -36,6 +38,7 @@
import org.hibernate.event.spi.EventSource;
import org.hibernate.event.spi.LockEvent;
import org.hibernate.event.spi.LockEventListener;
+import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.persister.entity.EntityPersister;
/**
@@ -46,7 +49,13 @@
*/
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.
* @throws HibernateException
@@ -61,6 +70,10 @@ public void onLock(LockEvent event) throws HibernateException {
throw new HibernateException( "Invalid lock mode for lock()" );
}
+ if ( event.getLockMode() == LockMode.UPGRADE_SKIPLOCKED ) {
+ LOG.explicitSkipLockedLockCombo();
+ }
+
SessionImplementor source = event.getSession();
Object entity = source.getPersistenceContext().unproxyAndReassociate( event.getObject() );
@@ -1609,4 +1609,11 @@ void cannotResolveNonNullableTransientDependencies(String transientEntityString,
)
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,5 +1,28 @@
<?xml version="1.0"?>
-<!DOCTYPE hibernate-mapping PUBLIC
+<!--
+ ~ 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
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
View
@@ -2,7 +2,7 @@
/*
* 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
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Inc.

0 comments on commit 4e126dc

Please sign in to comment.