-->
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.  [ 3 posts ] 
Author Message
 Post subject: hibernate.connection.release_mode in jboss-service.xml
PostPosted: Mon Jan 08, 2007 9:54 am 
Newbie

Joined: Mon Jan 08, 2007 9:26 am
Posts: 4
I'm using Hibernate 3.1.3 with Oracle 10 within JBOSS 4.0.4 as follows:
datasource definition (*-ds.xml) + jboss-service.xml + the *.hbm.xml mappings in a har. The problem I have is that that for each prepared statement Hibernate is getting a connection from the pool, but not releasing it after executing the prepared statement. Instead all connections are release at the end of the JTA transaction. I have seen in Hibernate documentation that for JTA I should set hibernate.connection.release_mode to after_statement.

I tried to set this in datasource and it had either no effect or I got errors:
Code:
<xa-datasource>
    <jndi-name>PublishingDB</jndi-name>
    <track-connection-by-tx/>
    <isSameRM-override-value>false</isSameRM-override-value>
    <xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</xa-datasource-class>
    <!-- xa-datasource-property name="URL">jdbc:oracle:oci8:@XE</xa-datasource-property -->
    <!-- xa-datasource-property name="URL">jdbc:oracle:thin:@localhost:1521:XE</xa-datasource-property -->
    <xa-datasource-property name="URL">PUBLISHING_DS_URL_TO_REPLACE</xa-datasource-property>
    <xa-datasource-property name="User">publishing</xa-datasource-property>
    <xa-datasource-property name="Password">PUBLISHING_DS_PWD_TO_REPLACE</xa-datasource-property>
    <!-- ERROR: method not found: ...
   <xa-datasource-property name="hibernate.connection.release_mode">auto</xa-datasource-property>
   -->
   <!-- NO EFFECT
   <connection-property name="hibernate.connection.release_mode">after_statement</connection-property>
   <connection-property name="hibernate.connection.aggressive_release">true</connection-property>
   -->
    <connection-property name="FetchTSWTZasTimestamp">true</connection-property>
    <!-- Uses the pingDatabase method to check a connection is still valid before handing it out from the pool -->
    <!--valid-connection-checker-class-name>
org.jboss.resource.adapter.jdbc.vendor.OracleValidConnectionChecker
</valid-connection-checker-class-name-->
    <!-- Checks the Oracle error codes and messages for fatal errors -->
    <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter</exception-sorter-class-name>
    <!-- Oracles XA datasource cannot reuse a connection outside a transaction once enlisted in a global transaction and vice-versa -->
    <no-tx-separate-pools/>

      <!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional) -->
      <metadata>
         <type-mapping>Oracle9i</type-mapping>
      </metadata>
  </xa-datasource>


I also tried in jboss-service.xml and I got errors:
Code:
<server>
   <mbean code="org.jboss.hibernate.jmx.Hibernate" name="jboss.jca:service=Hibernate,name=PublishingHibernate">
       <depends>jboss.jca:service=RARDeployer</depends>
       <attribute name="SessionFactoryName">java:/hibernate/PublishingSessionFactory</attribute>
       <attribute name="DatasourceName">java:/PublishingDB</attribute>
       <!-- attribute name="Dialect">org.hibernate.dialect.MySQLDialect</attribute -->
       <attribute name="Dialect">org.hibernate.dialect.Oracle9Dialect</attribute>
       <!--  ERROR: No Attribute found with name: hibernate.connection.aggressive_release
       <attribute name="hibernate.connection.aggressive_release">true</attribute>
       -->
       <!-- ERROR: No Attribute found with name: hibernate.connection.release_mode
       <attribute name="hibernate.connection.release_mode">auto</attribute>
       -->
       <!-- attribute name="DefaultSchema">profiling</attribute -->
       <attribute name="SecondLevelCacheEnabled">false</attribute>
       <!-- attribute name="CacheProviderClass">org.hibernate.cache.HashtableCacheProvider</attribute -->
       <attribute name="ShowSqlEnabled">false</attribute>
       <attribute name="JdbcBatchSize">30</attribute>
   </mbean>
</server>


Or using "org.hibernate.jmx.HibernateService", the jboss-service.xml became:
Code:
<server>
   <mbean code="org.hibernate.jmx.HibernateService" name="jboss.jca:service=HibernateFactory,name=PublishingHibernate">
       <depends>jboss.jca:service=RARDeployer</depends>
       <depends>jboss.jca:service=XATxCM,name=PublishingDB</depends>

       <attribute name="JndiName">java:/hibernate/PublishingSessionFactory</attribute>
       <attribute name="Datasource">java:/PublishingDB</attribute>
       <attribute name="Dialect">org.hibernate.dialect.Oracle9Dialect</attribute>
       <attribute name="SecondLevelCacheEnabled">false</attribute>
       <attribute name="ShowSqlEnabled">false</attribute>
     
       <attribute name="TransactionStrategy">org.hibernate.transaction.JTATransactionFactory</attribute>
       <attribute name="TransactionManagerLookupStrategy">org.hibernate.transaction.JBossTransactionManagerLookup</attribute>
       <attribute name="FlushBeforeCompletionEnabled">true</attribute>
       <attribute name="AutoCloseSessionEnabled">true</attribute>
       
       <attribute name="MapResources">publishing/dto/AccountMagazineRole.hbm.xml,
publishing/dto/Advert.hbm.xml,publishing/dto/AdvertUsage.hbm.xml,
publishing/dto/AdvertUsageSect.hbm.xml,publishing/dto/Asset.hbm.xml,
publishing/dto/CommonAsset.hbm.xml,publishing/dto/ConvAdvert.hbm.xml,
publishing/dto/ConvAsset.hbm.xml,publishing/dto/ConvRackBg.hbm.xml,
publishing/dto/Conversion.hbm.xml,publishing/dto/ConvertedItem.hbm.xml,
publishing/dto/Coupon.hbm.xml,publishing/dto/CouponType.hbm.xml,
publishing/dto/DynSectGen.hbm.xml,publishing/dto/Issue.hbm.xml,
publishing/dto/Magazine.hbm.xml,publishing/dto/MagazineRackTemplate.hbm.xml,
publishing/dto/ProdRetailer.hbm.xml,publishing/dto/Product.hbm.xml,
publishing/dto/Publisher.hbm.xml,publishing/dto/PublisherAccount.hbm.xml,
publishing/dto/PublisherAccountMagazine.hbm.xml,publishing/dto/RackTemplate.hbm.xml,
publishing/dto/RecurringModel.hbm.xml,publishing/dto/Retailer.hbm.xml,
publishing/dto/Role.hbm.xml,publishing/dto/Section.hbm.xml,
publishing/dto/SectionAdvert.hbm.xml,publishing/dto/Template.hbm.xml,
publishing/dto/TemplateCommonAsset.hbm.xml</attribute>
   
       <!-- ERROR: No Attribute found with name: property   
       <attribute name="property">
          <property name="hibernate.connection.release_mode">after_statement</property>
       </attribute-->

       <!-- NO EFFECT
       property name="hibernate.connection.release_mode">after_statement</property-->
   </mbean>
</server>


Where do I need to set the hibernate.connection.release_mode and how, because with the above explained structure (jboss-service.xml and *-ds.xml in a har) there are no hibernate.xml or hibernate.properties files.


Thank you very much,
Bucegi Omu


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 09, 2007 4:14 am 
Newbie

Joined: Mon Jan 08, 2007 9:26 am
Posts: 4
I forgot to mention that the reason for wanting to set the hibernate.connection.release_mode to after_statement is that I'm doing some massive deletes of a whole hierarchy of objects, then inserts of another massive hierarchy of objects, all these inserts and deletes in the same transaction (many of them using Hibernate cascadind) and I get from Oracle an error about maximum number of opened cursors exceeded. Of course, for the moment, I increased the maximum number of open cursors in Oracle dramatically to cover the needs of Hibernate, but this solution IS NOT SCALABLE! So I need either to configure Hibernate so that the connections are returned to pool after_statement, OR, if possible and perhaps even better, to make Hibernate reuse a connection (within a thread and a JTA transaction) from statement to statement (without getting a connection from the pool for each statement). About the second possibility I have absolutely no clue if it is possible and how.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 09, 2007 5:55 am 
Newbie

Joined: Mon Jan 08, 2007 9:26 am
Posts: 4
After more investigation it turned out that the Hibernate Service is already setting hibernate.connection.release_mode to after_statement as seen in the http://fisheye.jboss.com/browse/JBoss/hibernate/src/main/org/jboss/hibernate/jmx/Hibernate.java?r=1.3.2.19. I also found on Hibernate site the following "solution" fot "After a while, Oracle throws this exception: too many open cursors": http://www.hibernate.org/120.html#A10, which I doubt (at least so far), reason for which I opened another topic: Hibernate with Oracle: too many open cursors.

Could anybody help me with this?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.