2
When I try to execute the method Persistence.createEntityManagerFactory("Aluno")
class Persistence
i get the following error:
run:
abr 04, 2016 9:11:30 PM org.hibernate.ejb.HibernatePersistence logDeprecation
WARN: HHH015016: Encountered a deprecated javax.persistence.spi.PersistenceProvider [org.hibernate.ejb.HibernatePersistence]; use [org.hibernate.jpa.HibernatePersistenceProvider] instead.
abr 04, 2016 9:11:30 PM org.hibernate.ejb.HibernatePersistence logDeprecation
WARN: HHH015016: Encountered a deprecated javax.persistence.spi.PersistenceProvider [org.hibernate.ejb.HibernatePersistence]; use [org.hibernate.jpa.HibernatePersistenceProvider] instead.
abr 04, 2016 9:11:30 PM org.hibernate.ejb.HibernatePersistence logDeprecation
WARN: HHH015016: Encountered a deprecated javax.persistence.spi.PersistenceProvider [org.hibernate.ejb.HibernatePersistence]; use [org.hibernate.jpa.HibernatePersistenceProvider] instead.
Exception in thread "main" javax.persistence.PersistenceException: No Persistence provider for EntityManager named Aluno
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:61)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:39)
at hibernatetutorial.Main.main(Main.java:21)
Java Result: 1
CONSTRUÍDO COM SUCESSO (tempo total: 0 segundos)
In this message:
No Persistence Provider for Entitymanager named Student
He tells me there is no entity called Aluno
, however, in my persistence unit I have already defined the class of this entity. I have researched it, but have not found the solution of the problem.
Follow my persistence unit:
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
<persistence-unit name="HibernateTutorialPU" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<class>hibernatetutorial.Aluno</class>
<properties>
<property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/escolabd?zeroDateTimeBehavior=convertToNull"/>
<property name="javax.persistence.jdbc.user" value="root"/>
<property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver"/>
<property name="javax.persistence.jdbc.password" value="minhasenha"/>
<property name="hibernate.cache.provider_class" value="org.hibernate.cache.NoCacheProvider"/>
<property name="javax.persistence.schema-generation.database.action" value="create"/>
</properties>
</persistence-unit>
</persistence>
Follow the structure of my project:
Follow the libraries I’m using:
The IDE I’m using is the Netbeans IDE 8.0.2, and the Framework is Hibernate.
I passed the name of my persistence unit, but, not solved, gave another type of error see:
java.lang.NoClassDefFoundError: org/jboss/jandex/IndexView
.– gato
Did you manage to solve this problem? I am having the same difficulty, and I did the above steps but it did not work.
– Valdecir