JTATransaction

来源:互联网 发布:开展网络公益活动总结 编辑:程序博客网 时间:2024/06/05 19:53

JTATransaction

 

String jndiName = "java:/hibernate/JTASessionFactory";
InitialContext ctx = new InitialContext();
JTASessionFactory jtaf = (JTASessionFactory)ctx.lookup(jndiName);
Session session = jtaf.getSession();
ProductData data = (ProductData)session.load(ProductData.class, new
Integer(id));

Have I missed a point. Probably configuration problems. I deployed my
hibernate mappings as a sar/mbean with the following service
descriptor:

<mbean
  code="net.sf.hibernate.jmx.HibernateService"
 
name="jboss.jca:service=HibernateFactory,name=NorthwindHibernateFactory
">

  <!-- Make it deploy ONLY after DataSource had been started -->
  <depends>jboss.jca:service=RARDeployer</depends>
  <depends>jboss.jca:service=LocalTxCM,name=northwind</depends>
 
  <attribute name="MapResources"> 
    de/hal9000/northwind/mapping/ProductData.hbm.xml
  </attribute>
 
  <attribute
name="JndiName">java:/hibernate/NorthwindHibernateFactory</attribute>
  <attribute name="Datasource">java:/northwind</attribute>
  <attribute
name="Dialect">net.sf.hibernate.dialect.PostgreSQLDialect</attribute>
  <attribute
name="TransactionStrategy">net.sf.hibernate.transaction.JTATransactionF
actory</attribute>
  <attribute
name="TransactionManagerLookupStrategy">net.sf.hibernate.transaction.JB
ossTransactionManagerLookup</attribute>
  <attribute name="UseOuterJoin">true</attribute>
  <attribute name="ShowSql">false</attribute>
  <attribute
name="UserTransactionName">java:/UserTransaction</attribute>
</mbean>

 

 

The hibernate.cfg.xml file is as under
--------------------------------------------------

<?xml version="1.0" encoding="utf-8"?><!DOCTYPE hibernate-configuration    PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN"    "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"> <hibernate-configuration><session-factory> <!-- local connection properties --> <property name="hibernate.jndi.url">t3://localhost:7001</property> <property name="hibernate.jndi.class">weblogic.jndi.WLInitialContextFactory</property> <property name="hibernate.connection.datasource">castle/datasources/castle</property> <property name="hibernate.transaction.factory_class">org.hibernate.transaction.JTATransactionFactory</property> <property name="hibernate.transaction.manager_lookup_class">org.hibernate.transaction.WeblogicTransactionManagerLookup</property> <!-- This is required for weblogic! --><property name="hibernate.query.factory_class">org.hibernate.hql.classic.ClassicQueryTranslatorFactory</property> <!--  These are tunning properties set by Romulus after some tests. Please don't change these values whithout talking with Romulus!!!! --><property name="hibernate.max_fetch_depth">5</property><property name="hibernate.default_batch_fetch_size">250</property><property name="hibernate.cglib.use_reflection_optimizer">true</property>  <!-- cache settings --><property name="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</property><property name="hibernate.cache.use_query_cache">true</property>   <!-- dialect for Sybase --><property name="dialect">org.hibernate.dialect.SybaseDialect</property> <property name="hibernate.show_sql">false</property>   <mapping resource="castle/DescriptionType.hbm.xml" /><mapping resource="castle/Description.hbm.xml" /><mapping resource="castle/DescriptionGroupType.hbm.xml" /><mapping resource="castle/DescriptionGroup.hbm.xml" /> <mapping resource="castle/Source.hbm.xml" /><mapping resource="castle/DataSet.hbm.xml" /><mapping resource="castle/EditDetails.hbm.xml" /><mapping resource="castle/CastleType.hbm.xml" /> <mapping resource="castle/cds/CdsAction.hbm.xml" /><mapping resource="castle/cds/CdsMarketDataLabel.hbm.xml" /><mapping resource="castle/cds/CreditDefaultSwapAsset.hbm.xml" /><mapping resource="castle/cds/Issuer.hbm.xml" /><mapping resource="castle/cds/MarketDataLabel.hbm.xml" /><mapping resource="castle/cds/ReferenceObligation.hbm.xml" /><mapping resource="castle/cds/TransactionTermSet.hbm.xml" /> <mapping resource="castle/portfolio/AssetPortfolio.hbm.xml" /><mappingresource="castle/portfolio/AssetPortfolioAction.hbm.xml" /><mappingresource="castle/portfolio/AssetPortfolioMarketDataLabel.hbm.xml" /> <mapping resource="castle/cdi/CdiAction.hbm.xml" /><mapping resource="castle/cdi/CdiContractAction.hbm.xml" /><mappingresource="castle/cdi/CdiContractMarketDataLabel.hbm.xml" /><mapping resource="castle/cdi/CdiContract.hbm.xml" /><mapping resource="castle/cdi/CdiContractTrigger.hbm.xml" /><mapping resource="castle/cdi/CdiContractTriggerType.hbm.xml" /><mapping resource="castle/cdi/CdIndex.hbm.xml" /><mapping resource="castle/cdi/CdiTrancheAction.hbm.xml" /><mapping resource="castle/cdi/CdiTranche.hbm.xml" /> <mapping resource="castle/cdo/CdoAction.hbm.xml" /><mapping resource="castle/cdo/CdoMarketDataLabel.hbm.xml" /><mapping resource="castle/cdo/Cdo.hbm.xml" /><mapping resource="castle/cdo/CdoTrancheAction.hbm.xml" /><mapping resource="castle/cdo/CdoTranche.hbm.xml" />   </session-factory> </hibernate-configuration>