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