I am developing hibernation with a JPA project and am trying to get a persistence.xml working file using H2 (Embedded database).
persistence.xml
<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0"> <persistence-unit name="DefaultPersistenceUnit" transaction-type="RESOURCE_LOCAL"> <provider>org.hibernate.ejb.HibernatePersistence</provider> <class>entity.user</class> <properties> <property name="hibernate.connection.url" value="jdbc:h2:/~test" /> --> <property name="hibernate.dialect" value="org.hibernate.dialect.H2Dialect"></property> <property name="hibernate.connection.driver_class" value="org.h2.Driver" /> <property name="hibernate.connection.password" value="admin" /> <property name="hibernate.connection.username" value="admin" /> </properties> </persistence-unit> </persistence>
But this does not work, I always get an error
"Unable to create EntityManagerFactory"
EntityManagerFactory emf = Persistence.createEntityManagerFactory("DefaultPersistenceUnit");
. Can anyonw provide me with a working persistence.xml?
hibernate jpa h2
Gnanam
source share