[jboss-user] [JBossCache] - Re: TreeCache/Hibernate/JBossAS optimistic locking problem
steve.ebersole@jboss.com
do-not-reply at jboss.com
Tue Jul 11 14:25:27 EDT 2006
Here is the test to which I refer, which works (from the Hibernate test suite):
| public void testNoVersioningProvided() throws Throwable {
| // note : mimic query cache interactions...
| Fqn fqn = Fqn.fromString( "org/hibernate/querycache" );
| TreeCache treeCache = ( ( OptimisticTreeCacheProvider ) sfi().getSettings().getCacheProvider() ).getUnderlyingCache();
|
| Long long1 = new Long(1);
| Long long2 = new Long(2);
|
| Option option = new Option();
| option.setFailSilently( true );
|
| try {
| System.out.println( "****** General put... *******************************************" );
| DummyTransactionManager.INSTANCE.begin();
| treeCache.put( fqn, "ITEM1", long1, option );
| DummyTransactionManager.INSTANCE.commit();
| System.out.println( "****** General put... *******************************************" );
| DummyTransactionManager.INSTANCE.begin();
| treeCache.put( fqn, "ITEM1", long2, option );
| DummyTransactionManager.INSTANCE.commit();
|
| System.out.println( "****** General put... *******************************************" );
| DummyTransactionManager.INSTANCE.begin();
| treeCache.put( fqn, "ITEM2", long1, option );
| DummyTransactionManager.INSTANCE.commit();
|
| // try puts outside scope of transaction...
| System.out.println( "****** No-txn put... *******************************************" );
| treeCache.put( fqn, "ITEM1", long2, option );
| System.out.println( "****** No-txn put... *******************************************" );
| treeCache.put( fqn, "ITEM2", long2, option );
|
| // actual processing in handling a cached query
| System.out.println( "****** actual query cache put logic ****************************" );
| DummyTransactionManager.INSTANCE.begin();
| if ( treeCache.get( fqn, "ITEM3", option ) == null ) {
| // run the query, then put...
| treeCache.put( fqn, "ITEM3", long1, option );
| }
| System.out.println( "****** actual query cache put logic ****************************" );
| if ( treeCache.get( fqn, "ITEM3", option ) == null ) {
| // run the query, then put...
| treeCache.put( fqn, "ITEM3", long1, option );
| }
| DummyTransactionManager.INSTANCE.commit();
|
| // actual processing in handling a cached query (no txn)
| System.out.println( "****** actual query cache put logic ****************************" );
| if ( treeCache.get( fqn, "ITEM3", option ) == null ) {
| // run the query, then put...
| treeCache.put( fqn, "ITEM3", long1, option );
| }
| System.out.println( "****** actual query cache put logic ****************************" );
| if ( treeCache.get( fqn, "ITEM3", option ) == null ) {
| // run the query, then put...
| treeCache.put( fqn, "ITEM3", long1, option );
| }
| }
| finally {
| try {
| treeCache.remove( fqn, "ITEM1", option );
| treeCache.remove( fqn, "ITEM2", option );
| treeCache.remove( fqn, "ITEM3", option );
| }
| catch( Throwable ignore ) {
| }
| }
| }
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3957101#3957101
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3957101
More information about the jboss-user
mailing list