Hi,
I am trying to use hibernate within a CMT environment. Unfortunately i can't get it to work..
I would like to use CMT without the use of EJB if possible.
My goal is to encapsulate all my hibernate CRUDs within DAO objects without the need of calling the transaction api directly.
The JNDI Name of the JDBC Resources of the Glassfish server is: jdbc/databasePool
Name of the JDBC Connection Pool: database-pool
Following are the configuration files hibernate.cfg.xml and persistence.xml.
I appreciate any hint on how i can get it to work.
Glassfish is configured correctly.
thanks in advance.
hibernate.cfg.xml
Code:
<hibernate-configuration>
<session-factory>
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="hibernate.connection.datasource">jdbc/databasePool</property>
<property name="current_session_context_class">org.hibernate.context.JTASessionContext</property>
<property name="hibernate.transaction.factory_class">org.hibernate.transaction.CMTTransactionFactory</property>
<property name="hibernate.transaction.TransactionManager">org.hibernate.transaction.SunONETransactionManagerLookup</property>
<property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
<property name="show_sql">true</property>
<mapping class="com.test.hibernate.TestEntity"/>
</session-factory>
</hibernate-configuration>
persistence.xml
Code:
<persistence-unit name="PersistenceUnit" transaction-type="JTA">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>jdbc/databasePool</jta-data-source>
<class>com.test.hibernate.TestEntity</class>
<properties>
<property name="hibernate.connection.url" value="jdbc:mysql://localhost/testDatabase"/>
<property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"/>
<property name="hibernate.connection.username" value="root"/>
<property name="hibernate.connection.password" value="password"/>
<property name="hibernate.archive.autodetection" value="class"/>
<property name="hibernate.show_sql" value="true"/>
<property name="hibernate.format_sql" value="true"/>
</properties>
</persistence-unit>