-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 
Author Message
 Post subject: SQL Server lock hints not appearing?
PostPosted: Wed Feb 02, 2005 7:03 am 
Regular
Regular

Joined: Wed Feb 02, 2005 6:33 am
Posts: 70
Hi all,

I'm currently in the middle of evaluating Hibernate for use in a development project. Part of this evaluation is the testing of concurrency issues on various databases. So far, MySQL, Oracle and DB2/UDB have been run with these tests, and performed as expected. The db2/udb tests forced a move to Hibernate3 for the moment, to use the extra lock hints in the generated SQL.

The problem I've encountered is that the Lock Hints for MS SQL Server do not seem to be being incorporated into the final sql statements. The unit test that shows this problem is below. Since I'm fairly new to hibernate, I'm guessing this is a fairly trivial configuration problem (hence the inclusion of the configuration xml file), but I can't seem to track the problem down.

The debug output has been cut down, as there are a number of tests that run before this on in the test suite, if more debug is required then let me know.

The deployment is in JBoss AS 4.0.1, using the 'default' server configuration (unified classloader).

Hibernate version: 3 beta 2

Hibernate Configuration:

Code:
<hibernate-configuration>

    <session-factory>
        <property name="hibernate.connection.datasource">java:/lock_testingDS</property>
        <!-- Find other dialect specifications at
           http://www.hibernate.org/hib_docs/reference/en/html/session-configuration.html#configuration-optional-dialects -->
        <!-- <property name="dialect">org.hibernate.dialect.MySQLDialect</property> -->
        <!-- <property name="dialect">org.hibernate.dialect.DB2Dialect</property> -->
        <!-- <property name="dialect">org.hibernate.dialect.Oracle9Dialect</property> -->
        <property name="dialect">org.hibernate.dialect.SQLServerDialect</property>
        <property name="show_sql">true</property>
        <property name="transaction.factory_class">
             org.hibernate.transaction.JTATransactionFactory
        </property>
        <property name="jta.UserTransaction">
             java:comp/UserTransaction
        </property>
        <property name="hibernate.cache.provider_class">org.hibernate.cache.HashtableCacheProvider</property>
      <property name="TransactionStrategy">org.hibernate.transaction.JTATransactionFactory</property>
      <property name="TransactionManagerLookupStrategy">org.hibernate.transaction.JBossTransactionManagerLookup</property>
      <property name="hibernate.hbm2ddl.auto">create-drop</property>
      <property name="hibernate.query.factory_class">org.hibernate.hql.ast.ASTQueryTranslatorFactory</property>
        <mapping resource="com/dcs/lock_testing/entities/CustomerOrder.hbm.xml"/>

    </session-factory>

</hibernate-configuration>


Mapping documents:

Code:
<hibernate-mapping package="com.dcs.lock_testing.entities">

        <class name="CustomerOrder" table="CUSTOMER_ORDER">
                <id name="id" column="ID" type="string">
                        <generator class="uuid.hex"/>
                </id>
                <version column="VERSION"
                   name="version"
                   type="long"
                   access="property"
                   unsaved-value="negative"/>
                <property name="orderName" column="ORDER_NAME" type="string"/>
        </class>

</hibernate-mapping>


Code between sessionFactory.openSession() and session.close():
Code:
public class ConcurrentWriteTest  extends ServletTestCase {
   
   private static transient Log log = LogFactory.getLog(ConcurrentWriteTest.class);
   private boolean keepWaiting = true;
   public ConcurrentWriteTest(String name) {
      super(name);
   }
   public static Test suite() {
      return new TestSuite(ConcurrentWriteTest.class);
   }
   
   /**
    * Run before the tests, this sets up the test data
    */
   public void setUp() {
      try {
         TestDataGenerator.generateData();
      } catch (LockTestingException e) {
         log.error(e);
         assertTrue(false);
      }
   }
   
   /**
    * Run after the tests, this removes the test data
    */
   public void tearDown() {
      try {
         TestDataGenerator.removeGeneratedData();
      } catch (LockTestingException e) {
         log.error(e);
         assertTrue(false);
      }
   }

   public void testConcurrentWrite() throws Exception {
      WriteValuesThread[] writers = new WriteValuesThread[2];
      writers[0] = new WriteValuesThread("Thread 1");
      writers[1] = new WriteValuesThread("Thread 2");

      WakeupThread wt = new WakeupThread(this, 5000);
      wt.start();
      writers[0].start();
      while (!writers[0].valuesSet() && keepWaiting) {
         try {
            Thread.sleep(500);
         } catch (InterruptedException e) {
            log.error(e);
         }
      }
      if (!keepWaiting) {
         // we were woken up
         log.error("Writer didn't retrieve the entity within 5 secs");
         assertTrue(false);
         writers[0].continueToEnd();
         return;
      } else {
         wt.stopWaiting();
      }
      
      // set the wait time for 10 secs
      wt = new WakeupThread(this, 10000);
      wt.start();
      writers[1].start();
      while (!writers[1].valuesSet() && keepWaiting) {
         try {
            Thread.sleep(500);
         } catch (InterruptedException e) {
            log.error(e);
         }
      }
      if (!keepWaiting) {
         // we were woken up, so the queueing is working
      } else {
         log.error("Writer was not blocked for the full 10 secs");
         assertTrue(false);
         writers[0].continueToEnd();
         writers[1].continueToEnd();
         return;
      }
      writers[0].continueToEnd();
      writers[1].continueToEnd();
      assertTrue(true);
   }
   
   /**
    * Called by the wakeup thread to notify us that too much time has passed, so the test has failed
    *
    */
   public void wakeUp() {
      keepWaiting = false;
   }
   
   private class WakeupThread extends Thread {
      private ConcurrentWriteTest tester = null;
      private boolean continueWaiting = true;
      private int waitTime = 0;
      
      public WakeupThread(ConcurrentWriteTest tester, int waitTime) {
         this.tester = tester;
         this.waitTime = waitTime;
      }
      
      public void run() {
         for (int i = 0; i < 20 && continueWaiting; i++) {
            try {
               sleep(this.waitTime / 20);
            } catch (InterruptedException e) {
               log.error(e);
            }
         }
         if (continueWaiting)
            tester.wakeUp();
      }
      
      public void stopWaiting() {
         continueWaiting = false;
      }
   }

   private class WriteValuesThread extends Thread {
      
      String identifier = null;
      boolean running = true;
      boolean continueToEnd = false;
      boolean setValues = false;
      
      public WriteValuesThread(String name) {
         identifier = name;
      }
      
      /* (non-Javadoc)
       * @see java.lang.Runnable#run()
       */
      public void run() {
         log.debug(identifier + ": starting");

         SessionFactory factory = null;
         try {
            PersistenceManager.init();
            factory = PersistenceManager.sessionFactory();
         } catch (HibernateException e) {
            log.error(e);
            running = false;
         }
         
         Session session = null;
         Transaction tx = null;
         
         try {
            session = factory.openSession();
            session.connection().setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED);
              tx = session.beginTransaction();
             
              Query thisQuery = session.createQuery("from CustomerOrder as cord where cord.orderName = ?");
              thisQuery.setString(0, "NO LINES");
              thisQuery.setLockMode("cord", LockMode.UPGRADE);
            List orders = thisQuery.list();
            
            if (orders.size() > 0) {
               CustomerOrder thisOrder = (CustomerOrder)orders.get(0);
               thisOrder.setOrderName("NO LINES2");
               log.debug(identifier + ": got the name, sleeping");
               setValues = true;
               while (!continueToEnd && running) {
                  try {
                     Thread.sleep(500);
                  } catch (InterruptedException e) {
                     log.error(e);
                  }
               }
               session.saveOrUpdate(thisOrder);
            } else {
               log.error("No order with order name NO LINES created?");
            }
            
            
         } catch (SQLException e) {
            log.error(e);
            running = false;
         } catch (HibernateException e) {
            log.error(e);
            running = false;
         } finally {
            try {
               tx.commit();
               session.close();
            } catch (HibernateException e) {
               log.error(e);
               running = false;
            }
         }
         log.debug(identifier + ": finished running");
         running = false;
      }
      
      /**
       * @return Returns the running.
       */
      public boolean isRunning() {
         return running;
      }
      
      public void continueToEnd() {
         continueToEnd = true;
      }
      
      public boolean valuesSet() {
         return setValues;
      }
   }

}


Full stack trace of any exception that occurs:
No exception, just problem described above

Name and version of the database you are using:
MS SQL Server 2000 SP 3

The generated SQL (show_sql=true):

Code:
09:42:01,114 INFO  [STDOUT] Hibernate: select customeror0_.ID as ID, customeror0_.VERSION as VERSION0_, customeror0_.ORDER_NAME as ORDER_NAME0_ from CUSTOMER_ORDER customeror0_ where (customeror0_.ORDER_NAME=? )
09:42:01,615 INFO  [STDOUT] Hibernate: select customeror0_.ID as ID, customeror0_.VERSION as VERSION0_, customeror0_.ORDER_NAME as ORDER_NAME0_ from CUSTOMER_ORDER customeror0_ where (customeror0_.ORDER_NAME=? )
09:42:02,109 ERROR [ConcurrentWriteTest] Writer was not blocked for the full 10 secs


Debug level Hibernate log excerpt:

Code:
2005-02-02 09:40:55,953 INFO  [org.hibernate.cfg.Environment] Hibernate 3.0 beta 2
2005-02-02 09:40:55,959 INFO  [org.hibernate.cfg.Environment] hibernate.properties not found
2005-02-02 09:40:55,963 INFO  [org.hibernate.cfg.Environment] using CGLIB reflection optimizer
2005-02-02 09:40:55,964 INFO  [org.hibernate.cfg.Environment] using JDK 1.4 java.sql.Timestamp handling
2005-02-02 09:40:55,965 INFO  [org.hibernate.cfg.Configuration] configuring from resource: /hibernate.cfg.xml
2005-02-02 09:40:55,966 INFO  [org.hibernate.cfg.Configuration] Configuration resource: /hibernate.cfg.xml
2005-02-02 09:40:55,973 DEBUG [org.hibernate.util.DTDEntityResolver] trying to locate http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd in classpath under org/hibernate/
2005-02-02 09:40:55,974 DEBUG [org.hibernate.util.DTDEntityResolver] found http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd in classpath
2005-02-02 09:40:55,979 DEBUG [org.hibernate.cfg.Configuration] hibernate.connection.datasource=java:/lock_testingDS
2005-02-02 09:40:55,979 DEBUG [org.hibernate.cfg.Configuration] dialect=org.hibernate.dialect.SQLServerDialect
2005-02-02 09:40:55,979 DEBUG [org.hibernate.cfg.Configuration] show_sql=true
2005-02-02 09:40:55,979 DEBUG [org.hibernate.cfg.Configuration] transaction.factory_class=org.hibernate.transaction.JTATransactionFactory
2005-02-02 09:40:55,979 DEBUG [org.hibernate.cfg.Configuration] jta.UserTransaction=java:comp/UserTransaction
2005-02-02 09:40:55,979 DEBUG [org.hibernate.cfg.Configuration] hibernate.cache.provider_class=org.hibernate.cache.HashtableCacheProvider
2005-02-02 09:40:55,979 DEBUG [org.hibernate.cfg.Configuration] TransactionStrategy=org.hibernate.transaction.JTATransactionFactory
2005-02-02 09:40:55,979 DEBUG [org.hibernate.cfg.Configuration] TransactionManagerLookupStrategy=org.hibernate.transaction.JBossTransactionManagerLookup
2005-02-02 09:40:55,979 DEBUG [org.hibernate.cfg.Configuration] hibernate.hbm2ddl.auto=create-drop
2005-02-02 09:40:55,980 DEBUG [org.hibernate.cfg.Configuration] hibernate.query.factory_class=org.hibernate.hql.ast.ASTQueryTranslatorFactory
2005-02-02 09:40:55,980 DEBUG [org.hibernate.cfg.Configuration] null<-org.dom4j.tree.DefaultAttribute@304648 [Attribute: name resource value "com/dcs/lock_testing/entities/CustomerOrder.hbm.xml"]
2005-02-02 09:40:55,981 INFO  [org.hibernate.cfg.Configuration] Mapping resource: com/dcs/lock_testing/entities/CustomerOrder.hbm.xml
2005-02-02 09:40:55,983 DEBUG [org.hibernate.util.DTDEntityResolver] trying to locate http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd in classpath under org/hibernate/
2005-02-02 09:40:55,984 DEBUG [org.hibernate.util.DTDEntityResolver] found http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd in classpath
2005-02-02 09:40:56,524 INFO  [org.hibernate.cfg.HbmBinder] Mapping class: com.dcs.lock_testing.entities.CustomerOrder -> CUSTOMER_ORDER
2005-02-02 09:40:56,548 DEBUG [org.hibernate.cfg.HbmBinder] Mapped property: id -> ID
2005-02-02 09:40:56,549 DEBUG [org.hibernate.cfg.HbmBinder] Mapped property: version -> VERSION
2005-02-02 09:40:56,584 DEBUG [org.hibernate.cfg.HbmBinder] Mapped property: orderName -> ORDER_NAME

...

2005-02-02 09:42:01,106 DEBUG [com.dcs.lock_testing.tests.ConcurrentWriteTest] Thread 1: starting
2005-02-02 09:42:01,106 DEBUG [org.hibernate.impl.SessionImpl] opened session
2005-02-02 09:42:01,106 DEBUG [org.hibernate.jdbc.AbstractBatcher] opening JDBC connection
2005-02-02 09:42:01,107 DEBUG [org.hibernate.transaction.JTATransaction] Looking for UserTransaction under: java:comp/UserTransaction
2005-02-02 09:42:01,108 DEBUG [org.hibernate.transaction.JTATransaction] Obtained UserTransaction
2005-02-02 09:42:01,108 DEBUG [org.hibernate.transaction.JTATransaction] beginning new transaction
2005-02-02 09:42:01,108 DEBUG [org.hibernate.impl.SessionImpl] find: from CustomerOrder as cord where cord.orderName = ?
2005-02-02 09:42:01,108 DEBUG [org.hibernate.engine.QueryParameters] parameters: [NO LINES]
2005-02-02 09:42:01,108 DEBUG [org.hibernate.engine.QueryParameters] named parameters: {}
2005-02-02 09:42:01,109 DEBUG [org.hibernate.hql.ast.QueryTranslatorImpl] parse() - HQL: from com.dcs.lock_testing.entities.CustomerOrder as cord where cord.orderName = ?
2005-02-02 09:42:01,111 DEBUG [org.hibernate.hql.AST] --- HQL AST ---
\-'query' [QUERY]
    +-'SELECT_FROM' [SELECT_FROM]
    |  \-'from' [FROM]
    |     +-'.' [DOT]
    |     |  +-'.' [DOT]
    |     |  |  +-'.' [DOT]
    |     |  |  |  +-'.' [DOT]
    |     |  |  |  |  +-'com' [IDENT]
    |     |  |  |  |  \-'dcs' [IDENT]
    |     |  |  |  \-'lock_testing' [IDENT]
    |     |  |  \-'entities' [IDENT]
    |     |  \-'CustomerOrder' [IDENT]
    |     \-'cord' [ALIAS]
    \-'where' [WHERE]
       \-'=' [EQ]
          +-'.' [DOT]
          |  +-'cord' [IDENT]
          |  \-'orderName' [IDENT]
          \-'?' [PARAM]

2005-02-02 09:42:01,111 DEBUG [hql.parser] throwQueryException() : no errors
2005-02-02 09:42:01,111 DEBUG [org.hibernate.hql.antlr.HqlSqlBaseWalker] query() << begin, level = 1
2005-02-02 09:42:01,111 DEBUG [org.hibernate.hql.ast.FromElement] com.dcs.lock_testing.entities.CustomerOrder (cord) -> customeror0_
2005-02-02 09:42:01,111 DEBUG [org.hibernate.hql.ast.FromReferenceNode] Resolved :  cord -> customeror0_.ID
2005-02-02 09:42:01,111 DEBUG [org.hibernate.hql.ast.DotNode] getDataType() : orderName -> org.hibernate.type.StringType@fae93e
2005-02-02 09:42:01,111 DEBUG [org.hibernate.hql.ast.FromReferenceNode] Resolved :  cord.orderName -> customeror0_.ORDER_NAME
2005-02-02 09:42:01,112 DEBUG [org.hibernate.hql.antlr.HqlSqlBaseWalker] query() : finishing up...
2005-02-02 09:42:01,112 DEBUG [org.hibernate.hql.ast.HqlSqlWalker] Implied SELECT clause created.
2005-02-02 09:42:01,112 DEBUG [org.hibernate.hql.ast.JoinProcessor] Using FROM fragment [CUSTOMER_ORDER customeror0_]
2005-02-02 09:42:01,112 DEBUG [org.hibernate.hql.antlr.HqlSqlBaseWalker] query() >> end, level = 1
2005-02-02 09:42:01,114 DEBUG [org.hibernate.hql.AST] --- SQL AST ---
\-'SELECT' [SELECT]   querySpaces (CUSTOMER_ORDER)
    +-'{implicit select clause}' [SELECT_CLAUSE]
    |  +-'customeror0_.ID as ID' [SELECT_EXPR]  {FromElement{className=com.dcs.lock_testing.entities.CustomerOrder,explicit,not a collection join,classAlias=cord,tableName=CUSTOMER_ORDER,tableAlias=customeror0_,colums={}}}
    |  \-'customeror0_.VERSION as VERSION0_, customeror0_.ORDER_NAME as ORDER_NAME0_' [SQL_TOKEN]
    +-'from' [FROM]  FromClause{from}
    |  \-'CUSTOMER_ORDER customeror0_' [FROM_FRAGMENT]  FromElement{className=com.dcs.lock_testing.entities.CustomerOrder,explicit,not a collection join,classAlias=cord,tableName=CUSTOMER_ORDER,tableAlias=customeror0_,colums={}}
    \-'where' [WHERE]
       \-'=' [EQ]
          +-'customeror0_.ORDER_NAME' [DOT]  {propertyName=orderName,dereferenceType=DEREF_PRIMITIVE,propertyPath=orderName,path=cord.orderName,tableAlias=customeror0_,className=com.dcs.lock_testing.entities.CustomerOrder,classAlias=cord}
          |  +-'customeror0_.ID' [ALIAS_REF]  {alias=cord, className=com.dcs.lock_testing.entities.CustomerOrder, tableAlias=customeror0_}
          |  \-'orderName' [IDENT]  {originalText=orderName}
          \-'?' [PARAM]

2005-02-02 09:42:01,114 DEBUG [hql.parser] throwQueryException() : no errors
2005-02-02 09:42:01,114 DEBUG [org.hibernate.jdbc.AbstractBatcher] about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
2005-02-02 09:42:01,114 DEBUG [org.hibernate.SQL] select customeror0_.ID as ID, customeror0_.VERSION as VERSION0_, customeror0_.ORDER_NAME as ORDER_NAME0_ from CUSTOMER_ORDER customeror0_ where (customeror0_.ORDER_NAME=? )
2005-02-02 09:42:01,114 INFO  [STDOUT] Hibernate: select customeror0_.ID as ID, customeror0_.VERSION as VERSION0_, customeror0_.ORDER_NAME as ORDER_NAME0_ from CUSTOMER_ORDER customeror0_ where (customeror0_.ORDER_NAME=? )
2005-02-02 09:42:01,122 DEBUG [org.hibernate.jdbc.AbstractBatcher] preparing statement
2005-02-02 09:42:01,122 DEBUG [org.hibernate.type.StringType] binding 'NO LINES' to parameter: 1
2005-02-02 09:42:01,126 DEBUG [org.hibernate.jdbc.AbstractBatcher] about to open ResultSet (open ResultSets: 0, globally: 0)
2005-02-02 09:42:01,126 DEBUG [org.hibernate.loader.Loader] Using naked result set
2005-02-02 09:42:01,126 DEBUG [org.hibernate.loader.Loader] processing result set
2005-02-02 09:42:01,126 DEBUG [org.hibernate.type.StringType] returning 'ff80808101d271f00101d2729a1c0014' as column: ID
2005-02-02 09:42:01,126 DEBUG [org.hibernate.loader.Loader] result row: EntityKey[com.dcs.lock_testing.entities.CustomerOrder#ff80808101d271f00101d2729a1c0014]
2005-02-02 09:42:01,126 DEBUG [org.hibernate.loader.Loader] Initializing object from ResultSet: EntityKey[com.dcs.lock_testing.entities.CustomerOrder#ff80808101d271f00101d2729a1c0014]
2005-02-02 09:42:01,126 DEBUG [org.hibernate.persister.BasicEntityPersister] Hydrating entity: [com.dcs.lock_testing.entities.CustomerOrder#ff80808101d271f00101d2729a1c0014]
2005-02-02 09:42:01,126 DEBUG [org.hibernate.type.LongType] returning '0' as column: VERSION0_
2005-02-02 09:42:01,126 DEBUG [org.hibernate.type.StringType] returning 'NO LINES' as column: ORDER_NAME0_
2005-02-02 09:42:01,126 DEBUG [org.hibernate.engine.TwoPhaseLoad] Version: 0
2005-02-02 09:42:01,127 DEBUG [org.hibernate.loader.Loader] done processing result set (1 rows)
2005-02-02 09:42:01,127 DEBUG [org.hibernate.jdbc.AbstractBatcher] about to close ResultSet (open ResultSets: 1, globally: 1)
2005-02-02 09:42:01,128 DEBUG [org.hibernate.jdbc.AbstractBatcher] about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
2005-02-02 09:42:01,128 DEBUG [org.hibernate.jdbc.AbstractBatcher] closing statement
2005-02-02 09:42:01,128 DEBUG [org.hibernate.loader.Loader] total objects hydrated: 1
2005-02-02 09:42:01,128 DEBUG [org.hibernate.engine.TwoPhaseLoad] resolving associations for [com.dcs.lock_testing.entities.CustomerOrder#ff80808101d271f00101d2729a1c0014]
2005-02-02 09:42:01,128 DEBUG [org.hibernate.type.PersistentCollectionType] creating collection wrapper:[com.dcs.lock_testing.entities.CustomerOrder.customerOrderLines#ff80808101d271f00101d2729a1c0014]
2005-02-02 09:42:01,129 DEBUG [org.hibernate.engine.TwoPhaseLoad] done materializing entity [com.dcs.lock_testing.entities.CustomerOrder#ff80808101d271f00101d2729a1c0014]
2005-02-02 09:42:01,129 DEBUG [org.hibernate.impl.PersistenceContext] initializing non-lazy collections
2005-02-02 09:42:01,129 DEBUG [com.dcs.lock_testing.tests.ConcurrentWriteTest] Thread 1: got the name, sleeping
2005-02-02 09:42:01,607 DEBUG [com.dcs.lock_testing.tests.ConcurrentWriteTest] Thread 2: starting
2005-02-02 09:42:01,607 DEBUG [org.hibernate.impl.SessionImpl] opened session
2005-02-02 09:42:01,607 DEBUG [org.hibernate.jdbc.AbstractBatcher] opening JDBC connection
2005-02-02 09:42:01,609 DEBUG [org.hibernate.transaction.JTATransaction] Looking for UserTransaction under: java:comp/UserTransaction
2005-02-02 09:42:01,609 DEBUG [org.hibernate.transaction.JTATransaction] Obtained UserTransaction
2005-02-02 09:42:01,609 DEBUG [org.hibernate.transaction.JTATransaction] beginning new transaction
2005-02-02 09:42:01,609 DEBUG [org.hibernate.impl.SessionImpl] find: from CustomerOrder as cord where cord.orderName = ?
2005-02-02 09:42:01,609 DEBUG [org.hibernate.engine.QueryParameters] parameters: [NO LINES]
2005-02-02 09:42:01,609 DEBUG [org.hibernate.engine.QueryParameters] named parameters: {}
2005-02-02 09:42:01,610 DEBUG [org.hibernate.hql.ast.QueryTranslatorImpl] parse() - HQL: from com.dcs.lock_testing.entities.CustomerOrder as cord where cord.orderName = ?
2005-02-02 09:42:01,612 DEBUG [org.hibernate.hql.AST] --- HQL AST ---
\-'query' [QUERY]
    +-'SELECT_FROM' [SELECT_FROM]
    |  \-'from' [FROM]
    |     +-'.' [DOT]
    |     |  +-'.' [DOT]
    |     |  |  +-'.' [DOT]
    |     |  |  |  +-'.' [DOT]
    |     |  |  |  |  +-'com' [IDENT]
    |     |  |  |  |  \-'dcs' [IDENT]
    |     |  |  |  \-'lock_testing' [IDENT]
    |     |  |  \-'entities' [IDENT]
    |     |  \-'CustomerOrder' [IDENT]
    |     \-'cord' [ALIAS]
    \-'where' [WHERE]
       \-'=' [EQ]
          +-'.' [DOT]
          |  +-'cord' [IDENT]
          |  \-'orderName' [IDENT]
          \-'?' [PARAM]

2005-02-02 09:42:01,612 DEBUG [hql.parser] throwQueryException() : no errors
2005-02-02 09:42:01,612 DEBUG [org.hibernate.hql.antlr.HqlSqlBaseWalker] query() << begin, level = 1
2005-02-02 09:42:01,612 DEBUG [org.hibernate.hql.ast.FromElement] com.dcs.lock_testing.entities.CustomerOrder (cord) -> customeror0_
2005-02-02 09:42:01,613 DEBUG [org.hibernate.hql.ast.FromReferenceNode] Resolved :  cord -> customeror0_.ID
2005-02-02 09:42:01,613 DEBUG [org.hibernate.hql.ast.DotNode] getDataType() : orderName -> org.hibernate.type.StringType@fae93e
2005-02-02 09:42:01,613 DEBUG [org.hibernate.hql.ast.FromReferenceNode] Resolved :  cord.orderName -> customeror0_.ORDER_NAME
2005-02-02 09:42:01,613 DEBUG [org.hibernate.hql.antlr.HqlSqlBaseWalker] query() : finishing up...
2005-02-02 09:42:01,613 DEBUG [org.hibernate.hql.ast.HqlSqlWalker] Implied SELECT clause created.
2005-02-02 09:42:01,613 DEBUG [org.hibernate.hql.ast.JoinProcessor] Using FROM fragment [CUSTOMER_ORDER customeror0_]
2005-02-02 09:42:01,613 DEBUG [org.hibernate.hql.antlr.HqlSqlBaseWalker] query() >> end, level = 1
2005-02-02 09:42:01,614 DEBUG [org.hibernate.hql.AST] --- SQL AST ---
\-'SELECT' [SELECT]   querySpaces (CUSTOMER_ORDER)
    +-'{implicit select clause}' [SELECT_CLAUSE]
    |  +-'customeror0_.ID as ID' [SELECT_EXPR]  {FromElement{className=com.dcs.lock_testing.entities.CustomerOrder,explicit,not a collection join,classAlias=cord,tableName=CUSTOMER_ORDER,tableAlias=customeror0_,colums={}}}
    |  \-'customeror0_.VERSION as VERSION0_, customeror0_.ORDER_NAME as ORDER_NAME0_' [SQL_TOKEN]
    +-'from' [FROM]  FromClause{from}
    |  \-'CUSTOMER_ORDER customeror0_' [FROM_FRAGMENT]  FromElement{className=com.dcs.lock_testing.entities.CustomerOrder,explicit,not a collection join,classAlias=cord,tableName=CUSTOMER_ORDER,tableAlias=customeror0_,colums={}}
    \-'where' [WHERE]
       \-'=' [EQ]
          +-'customeror0_.ORDER_NAME' [DOT]  {propertyName=orderName,dereferenceType=DEREF_PRIMITIVE,propertyPath=orderName,path=cord.orderName,tableAlias=customeror0_,className=com.dcs.lock_testing.entities.CustomerOrder,classAlias=cord}
          |  +-'customeror0_.ID' [ALIAS_REF]  {alias=cord, className=com.dcs.lock_testing.entities.CustomerOrder, tableAlias=customeror0_}
          |  \-'orderName' [IDENT]  {originalText=orderName}
          \-'?' [PARAM]

2005-02-02 09:42:01,615 DEBUG [hql.parser] throwQueryException() : no errors
2005-02-02 09:42:01,615 DEBUG [org.hibernate.jdbc.AbstractBatcher] about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
2005-02-02 09:42:01,615 DEBUG [org.hibernate.SQL] select customeror0_.ID as ID, customeror0_.VERSION as VERSION0_, customeror0_.ORDER_NAME as ORDER_NAME0_ from CUSTOMER_ORDER customeror0_ where (customeror0_.ORDER_NAME=? )
2005-02-02 09:42:01,615 INFO  [STDOUT] Hibernate: select customeror0_.ID as ID, customeror0_.VERSION as VERSION0_, customeror0_.ORDER_NAME as ORDER_NAME0_ from CUSTOMER_ORDER customeror0_ where (customeror0_.ORDER_NAME=? )
2005-02-02 09:42:01,623 DEBUG [org.hibernate.jdbc.AbstractBatcher] preparing statement
2005-02-02 09:42:01,623 DEBUG [org.hibernate.type.StringType] binding 'NO LINES' to parameter: 1
2005-02-02 09:42:01,626 DEBUG [org.hibernate.jdbc.AbstractBatcher] about to open ResultSet (open ResultSets: 0, globally: 0)
2005-02-02 09:42:01,626 DEBUG [org.hibernate.loader.Loader] Using naked result set
2005-02-02 09:42:01,626 DEBUG [org.hibernate.loader.Loader] processing result set
2005-02-02 09:42:01,627 DEBUG [org.hibernate.type.StringType] returning 'ff80808101d271f00101d2729a1c0014' as column: ID
2005-02-02 09:42:01,627 DEBUG [org.hibernate.loader.Loader] result row: EntityKey[com.dcs.lock_testing.entities.CustomerOrder#ff80808101d271f00101d2729a1c0014]
2005-02-02 09:42:01,627 DEBUG [org.hibernate.loader.Loader] Initializing object from ResultSet: EntityKey[com.dcs.lock_testing.entities.CustomerOrder#ff80808101d271f00101d2729a1c0014]
2005-02-02 09:42:01,627 DEBUG [org.hibernate.persister.BasicEntityPersister] Hydrating entity: [com.dcs.lock_testing.entities.CustomerOrder#ff80808101d271f00101d2729a1c0014]
2005-02-02 09:42:01,627 DEBUG [org.hibernate.type.LongType] returning '0' as column: VERSION0_
2005-02-02 09:42:01,627 DEBUG [org.hibernate.type.StringType] returning 'NO LINES' as column: ORDER_NAME0_
2005-02-02 09:42:01,627 DEBUG [org.hibernate.engine.TwoPhaseLoad] Version: 0
2005-02-02 09:42:01,628 DEBUG [org.hibernate.loader.Loader] done processing result set (1 rows)
2005-02-02 09:42:01,628 DEBUG [org.hibernate.jdbc.AbstractBatcher] about to close ResultSet (open ResultSets: 1, globally: 1)
2005-02-02 09:42:01,629 DEBUG [org.hibernate.jdbc.AbstractBatcher] about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
2005-02-02 09:42:01,629 DEBUG [org.hibernate.jdbc.AbstractBatcher] closing statement
2005-02-02 09:42:01,629 DEBUG [org.hibernate.loader.Loader] total objects hydrated: 1
2005-02-02 09:42:01,629 DEBUG [org.hibernate.engine.TwoPhaseLoad] resolving associations for [com.dcs.lock_testing.entities.CustomerOrder#ff80808101d271f00101d2729a1c0014]
2005-02-02 09:42:01,629 DEBUG [org.hibernate.type.PersistentCollectionType] creating collection wrapper:[com.dcs.lock_testing.entities.CustomerOrder.customerOrderLines#ff80808101d271f00101d2729a1c0014]
2005-02-02 09:42:01,629 DEBUG [org.hibernate.engine.TwoPhaseLoad] done materializing entity [com.dcs.lock_testing.entities.CustomerOrder#ff80808101d271f00101d2729a1c0014]
2005-02-02 09:42:01,629 DEBUG [org.hibernate.impl.PersistenceContext] initializing non-lazy collections
2005-02-02 09:42:01,629 DEBUG [com.dcs.lock_testing.tests.ConcurrentWriteTest] Thread 2: got the name, sleeping
2005-02-02 09:42:02,109 ERROR [com.dcs.lock_testing.tests.ConcurrentWriteTest] Writer was not blocked for the full 10 secs


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 02, 2005 8:24 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Actually, the SQL server lock hint is not currently applied to queries. It does work for get()/load().

I should will this to TODO


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 02, 2005 11:32 am 
Regular
Regular

Joined: Wed Feb 02, 2005 6:33 am
Posts: 70
Ah, that explains it then :)

Is there a known target release for this feature?

Cheers


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 15, 2005 4:45 pm 
Newbie

Joined: Thu Apr 15, 2004 10:17 am
Posts: 14
Location: Manhattan
We have a need lock hints, specifically the "with (NOLOCK)" clause on select queries as well. We are currently using Hibernate 2 and had to download the source and modify it to add the no lock hints on select queries. While we are not adverse to doing this again with Hibernate 3 we'd, of course, prefer it to be supported.

_________________
4 9 7 23 5 5 4


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 17, 2005 12:57 pm 
Regular
Regular

Joined: Mon Sep 29, 2003 9:39 am
Posts: 67
Why not create a view and apply the lock there?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.