Hello,
I use org.jboss.hibernate.jmx.Hibernate MBean for my hibernate application with following deploy file:
<mbean code="org.jboss.hibernate.jmx.Hibernate" name="jboss.har:service=Hibernate"> <depends>jboss.jca:service=RARDeployer</depends> <depends>jboss.jca:service=LocalTxCM,name=DerbyDS</depends> <attribute name="SessionFactoryName"> java:/hibernate/SessionFactory </attribute> <attribute name="DatasourceName">java:DerbyDS</attribute> <attribute name="Dialect"> org.hibernate.dialect.DerbyDialect </attribute> <attribute name="CacheProviderClass"> org.hibernate.cache.NoCacheProvider </attribute> <attribute name="ShowSqlEnabled">true</attribute> <!-- attribute name="ScanForMappingsEnabled">true</attribute--> </mbean>
<?xml version="1.0" encoding="UTF-8"?> <server> <mbean code="org.jboss.tm.XidFactory" name="jboss:service=XidFactory"> </mbean> <mbean code="org.jboss.tm.TransactionManagerService" name="jboss:service=TransactionManager"> <attribute name="TransactionTimeout">300</attribute> <attribute name="GlobalIdsEnabled">true</attribute> <depends optional-attribute-name="XidFactory"> jboss:service=XidFactory </depends> </mbean> </server>
InitialContext ctx=new InitialContext(); factory=(SessionFactory)ctx.lookup("java:/hibernate/SessionFactory"); // session = factory.getCurrentSession(); session=factory.openSession(); session.getTransaction().begin();