views:
53answers:
1Hi guys,
I am trying to create a new JEE project using hibernate and JPA 2.0 on the glass fish server.Can you guys provide me some resources to configure the above so that they work seemlessly. I have tried using netbeans and generated the persistence unit by using the hibernate provider,but i end up getting this error
javax.persistence.PersistenceException: [PersistenceUnit: DBAppPU] Unable to build EntityManagerFactory
I am new to all this technologies so i am looking for good resource to learn also.Your help will be greatly appreciated :)
Thanks!
+1
A:
First, install Hibernate support via the update tool (or follow the manual procedure). Second, provide a JPA 2.0 persistence.xml
to use Hibernate as JPA provider:
<persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd" version="2.0">
<persistence-unit name="MyPu" transaction-type="JTA">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<!-- JNDI name of the database resource to use -->
<jta-data-source>jdbc/__default</jta-data-source>
<properties>
<!-- The database dialect to use -->
<property name="hibernate.dialect" value="org.hibernate.dialect.DerbyDialect" />
<!-- update database tables at deployment -->
<property name="hibernate.hbm2ddl.auto" value="update"/>
<!-- log the generated SQL -->
<property name="hibernate.show_sql" value="true"/>
</properties>
</persistence-unit>
</persistence>
Resources
- Using Hibernate as JPA Provider for GlassFish V3 (via update tool)
- Use Hibernate as a persistence provider with Glassfish (manual procedure)
- JPA with Hibernate on Glassfish 3
Pascal Thivent
2010-08-31 16:58:54
Thanks pascal, you are a true guru.I just realized that the hibernate libraries should be put on the servers folder.
BinCode
2010-09-01 11:00:13
Now i dont get any error but nothing turns up in the display .On checking the logs i see the followingNot binding factory to JNDI, no JNDI name configured
BinCode
2010-09-01 13:38:52
@BinCode Did you configure a particular datasource? What is its JNDI name? Could you test it successfully in the admin console? Also please show your `persistence.xml`.
Pascal Thivent
2010-09-01 13:51:18
i have added my files below please check and let me know what am i doing wrong thanks.
BinCode
2010-09-02 06:44:27
Assistance required :D
BinCode
2010-09-03 00:07:58
@BinCode I'll take a look at your problem but please open a new question. My answer covered your initial question. The current problem (even if related) is a new one and it's a best practice to not mix problems in a question (on top of that, my answer now looks odd now). So please open a new question and revert the body of this one to the one of the first revisions.
Pascal Thivent
2010-09-03 00:32:21
Sure will do that Thanks!
BinCode
2010-09-03 00:37:52