-->
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.  [ 1 post ] 
Author Message
 Post subject: hibernate - container managed transaction - glassfish
PostPosted: Sun Sep 19, 2010 7:42 pm 
Newbie

Joined: Sun Sep 19, 2010 6:59 pm
Posts: 1
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>


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.