Error in creating an EntityManagerFactory using Persistence.createEntityManagerFactory

0

Application in NetBens 8.2

MySQL Database

BD connector: jdbc 8.0

HIbernet 4.3.x

This is my persistence.xml class within the META-INF

<?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="FotocopiadoraV3PU" transaction-type="RESOURCE_LOCAL">

        <provider>org.hibernate.ejb.HibernatePersistence</provider>

        <class>fotocopiadorav3.Modelo.AlfaNumerico</class>

        <validation-mode>NONE</validation-mode>
        <properties>
            <property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver"/>
            <property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/fotocopiadora"/>
            <property name="javax.persistence.jdbc.user" value="root"/>
            <property name="javax.persistence.jdbc.password" value=""/>
            <property name="hibernate.cache.provider_class" value="org.hibernate.cache.NoCacheProvider"/>
            <property name="javax.persistence.schema-generation.database.action" value="create"/>
            <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialec"/>
            <property name="hibernate.hbm2ddl.auto" value="create"/>
        </properties>
    </persistence-unit>
</persistence>

This is my class that implements where the error occurs

package fotocopiadorav3.Modelo;

import java.util.Collections;
import java.util.List;
import javax.persistence.*;

public class TestAlfaNumerico {

    private static EntityManager manager;

    private static EntityManagerFactory emf;

    public static void main(String[] args) {

    emf = Persistence.createEntityManagerFactory("FotocopiadoraV3PU");

    manager = emf.createEntityManager();

    String query = "FROM " + AlfaNumerico.getClase();

    List<AlfaNumerico> conjunto = (List<AlfaNumerico>) manager.createQuery(query).getResultList();
    System.out.println("Hay " + conjunto.size() + "lineas");

    }

}

and the error occurs in this line, especially

emf = Persistence.createEntityManagerFactory("FotocopiadoraV3PU");

and this error occurs

Exception in thread "main" javax.persistence.PersistenceException: Unable to build entity manager factory
    at org.hibernate.jpa.HibernatePersistenceProvider.createEntityManagerFactory(HibernatePersistenceProvider.java:81)
    at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:54)
    at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:55)
    at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:39)
    at fotocopiadorav3.Modelo.TestAlfaNumerico.main(TestAlfaNumerico.java:46)
    
asked by tomas co 16.10.2018 в 19:11
source

0 answers