I am trying to create a new Java EE 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 seamlessly? 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
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>