[hibernate-commits] Hibernate SVN: r11473 - in trunk/HibernateExt/shards/src: test/org/hibernate/shards/integration/model and 1 other directory.
hibernate-commits at lists.jboss.org
hibernate-commits at lists.jboss.org
Mon May 7 00:13:58 EDT 2007
Author: max.ross
Date: 2007-05-07 00:13:58 -0400 (Mon, 07 May 2007)
New Revision: 11473
Modified:
trunk/HibernateExt/shards/src/java/org/hibernate/shards/session/ShardedSessionImpl.java
trunk/HibernateExt/shards/src/test/org/hibernate/shards/integration/model/ModelPermutedIntegrationTest.java
Log:
http://opensource.atlassian.com/projects/hibernate/browse/HSHARDS-28
Implemented ShardedSessionImpl.getCurrentLockMode()
Modified: trunk/HibernateExt/shards/src/java/org/hibernate/shards/session/ShardedSessionImpl.java
===================================================================
--- trunk/HibernateExt/shards/src/java/org/hibernate/shards/session/ShardedSessionImpl.java 2007-05-07 00:30:03 UTC (rev 11472)
+++ trunk/HibernateExt/shards/src/java/org/hibernate/shards/session/ShardedSessionImpl.java 2007-05-07 04:13:58 UTC (rev 11473)
@@ -967,11 +967,19 @@
throw new UnsupportedOperationException();
}
- /**
- * Unsupported. This is a scope decision, not a technical decision.
- */
public LockMode getCurrentLockMode(Object object) throws HibernateException {
- throw new UnsupportedOperationException();
+ ShardId shardId = getShardIdForObject(object);
+ Session sessionToUse;
+ if (shardId == null) {
+ // just ask this question of a random shard so we get the proper error
+ sessionToUse = getSomeSession();
+ if (sessionToUse == null) {
+ sessionToUse = shards.get(0).establishSession();
+ }
+ } else {
+ sessionToUse = shardIdsToShards.get(shardId).establishSession();
+ }
+ return sessionToUse.getCurrentLockMode(object);
}
public Transaction beginTransaction() throws HibernateException {
Modified: trunk/HibernateExt/shards/src/test/org/hibernate/shards/integration/model/ModelPermutedIntegrationTest.java
===================================================================
--- trunk/HibernateExt/shards/src/test/org/hibernate/shards/integration/model/ModelPermutedIntegrationTest.java 2007-05-07 00:30:03 UTC (rev 11472)
+++ trunk/HibernateExt/shards/src/test/org/hibernate/shards/integration/model/ModelPermutedIntegrationTest.java 2007-05-07 04:13:58 UTC (rev 11473)
@@ -19,6 +19,7 @@
package org.hibernate.shards.integration.model;
import org.hibernate.HibernateException;
+import org.hibernate.LockMode;
import org.hibernate.SessionFactory;
import org.hibernate.TransactionException;
import org.hibernate.classic.Session;
@@ -929,6 +930,19 @@
assertNull(b);
}
+ public void testGetCurrentLockMode() {
+ session.beginTransaction();
+ Building b = building("b1");
+ try {
+ session.getCurrentLockMode(b);
+ fail("expected he");
+ } catch (HibernateException he) {
+ // good
+ }
+ session.save(b);
+ assertEquals(LockMode.WRITE, session.getCurrentLockMode(b));
+ }
+
// this is a really good way to shake out synchronization bugs
public void xtestOverAndOver() throws Exception {
final boolean[] go = {true};
More information about the hibernate-commits
mailing list