Hi,
i would like to program against the Java Persistence API using Hibernate. My current code looks like this:
Code:
public static void main(String[] args) {
Class.forName("org.hsqldb.jdbcDriver").newInstance();
// start persistence
final EntityManagerFactory factory = Persistence.createEntityManagerFactory("gse");
final EntityManager manager = factory.createEntityManager();
}
This throws a NoSuchMethodError if i use Hibernate 3.2CR2 and a ClassNotFoundException if i use Hibernate 3.2CR1. I guess these libraries of Hibernate, Hibernate Annotations and Hibernate EntityManager are some kind of incompatible. Is there an version known to work?
Thanks,
Alexander
Hibernate version: Hibernate 3.2 CR1
Hibernate 3.2.CR2
Hibernate Annotations 3.2.0 CR1
Hibernate EntityManager 3.2.0 CR1
Mapping documents:In my case this is the persistence.xml in the folder META-INF/
Code:
<?xml version="1.0" encoding="UTF-8"?>
<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_1_0.xsd"
version="1.0">
<!-- external database setup -->
<!--
<persistence-unit name="sample" transaction-type="RESOURCE_LOCAL">
<class>addressbook.Person</class>
<properties>
<property name="hibernate.connection.driver_class" value="org.hsqldb.jdbcDriver"/>
<property name="hibernate.connection.username" value="sa"/>
<property name="hibernate.connection.password" value=""/>
<property name="hibernate.connection.url" value="jdbc:hsqldb:hsql://localhost"/>
<property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect"/>
<property name="hibernate.hbm2ddl.auto" value="update"/>
</properties>
</persistence-unit>
-->
<!-- in-process database setup -->
<persistence-unit name="gse" transaction-type="RESOURCE_LOCAL">
<class>de.informus.gse.data.Area</class>
<class>de.informus.gse.data.Category</class>
<class>de.informus.gse.data.File</class>
<class>de.informus.gse.data.MapMarker</class>
<class>de.informus.gse.data.Metadata</class>
<class>de.informus.gse.data.PointOfContact</class>
<class>de.informus.gse.data.PolicyDriver</class>
<class>de.informus.gse.data.Product</class>
<class>de.informus.gse.data.ProductType</class>
<class>de.informus.gse.data.Quicklook</class>
<class>de.informus.gse.data.Resource</class>
<class>de.informus.gse.data.ServiceActor</class>
<class>de.informus.gse.data.ServiceCase</class>
<class>de.informus.gse.data.ServiceProvider</class>
<class>de.informus.gse.data.ServiceType</class>
<class>de.informus.gse.data.ServiceUser</class>
<class>de.informus.gse.data.Time</class>
<properties>
<property name="hibernate.connection.driver_class" value="org.hsqldb.jdbcDriver"/>
<property name="hibernate.connection.username" value="sa"/>
<property name="hibernate.connection.password" value=""/>
<property name="hibernate.connection.url" value="jdbc:hsqldb:GsefmDB"/>
<property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect"/>
<property name="hibernate.hbm2ddl.auto" value="update"/>
</properties>
</persistence-unit>
</persistence>
Code between sessionFactory.openSession() and session.close():Full stack trace of any exception that occurs:Exception in thread "main" java.lang.NoSuchMethodError: org.hibernate.cfg.AnnotationConfiguration.setEntityNotFoundDelegate(Lorg/hibernate/proxy/EntityNotFoundDelegate;)V
at org.hibernate.ejb.Ejb3Configuration.<init>(Ejb3Configuration.java:94)
at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:113)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:37)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:27)
Name and version of the database you are using:The generated SQL (show_sql=true):Debug level Hibernate log excerpt:Code: