2 Replies Latest reply on Feb 7, 2006 8:33 PM by Andrew Davey

    Hibernate Locking Problem

    Andrew Davey Newbie

      We have a problem with table locking using JBoss 4.0.2, Hibernate 3.0.5 and Ingres 2.6. We have a script that inserts into a table on a fairly regular basis (yes it commits afterwards). Our application then comes along and tries to read from that table and it sits there waiting indefinately. It doesn't happen all the time and we think it only happens when the insert and select are run at the same time. Everything is run through a session bean with JBoss managing the opening and closing of session.

      Here is the mapping:

      <!DOCTYPE hibernate-mapping PUBLIC
       "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
       "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
      <hibernate-mapping>
       <class name="DocketLocationDAO" table="DOCKET_LOCATION" >
      
       <id name="jobNumber"
       type="integer"
       column="albook_k">
       <generator class="native"/>
       </id>
      
       <property name="docketNumber"
       type="string"
       column="madocket_k"
       update="false"
       insert="false" />
      
       <property name="tableName"
       type="string"
       column="table_name"
       update="false"
       insert="false"/>
      
       <property name="destinationPostcode"
       type="string"
       column="dest_postcode"
       update="false"
       insert="false"/>
      
       </class>
      </hibernate-mapping>


      Here is the source:
      public static List<DocketLocationDAO> getJobLocations(String docketNumber,
       Session session) throws Exception
       {
       List<DocketLocationDAO> docketLocations = null;
      
       try
       {
       Criteria criteria = session.createCriteria(DocketLocationDAO.class);
       criteria.add(Restrictions.eq("docketNumber", docketNumber));
       criteria.addOrder(Order.asc("docketNumber"));
       criteria.setLockMode(LockMode.NONE);
      
       docketLocations = criteria.list();
       }
       catch (Exception exception)
       {
       throw new Exception("Exception thrown in DocketLocationRetriever.getJobLocation : "
       + exception.toString());
       }
      
       return docketLocations;
       }
      


      We are really stuck for ideas now and are hoping for some input to our problem.

      Thanks,
      Andrew