Hibernate does not create table in database

0

The event model is an entity that must be created in the database, but hibernate is not creating.

persistence.xml

<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="org.hibernate.tutorial.jpa"
    transaction-type="RESOURCE_LOCAL">
    <description>
        Persistence unit for the JPA tutorial of the Hibernate Getting Started Guide
    </description>
    <provider>org.hibernate.ejb.HibernatePersistence</provider>

    <class>org.halyph.sessiondemo.Event</class>
    <class>com.eventos.eventos.models.Evento</class>

    <properties>
        <!-- dados da conexao -->
        <property name="javax.persistence.jdbc.driver" value="com.mysql.cj.jdbc.Driver" />
        <property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/eventosapp" />
        <property name="javax.persistence.jdbc.user" value="root" />
        <property name="javax.persistence.jdbc.password" value="" />

        <!-- propriedades do hibernate -->
        <property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5InnoDBDialect" />
        <property name="hibernate.show_sql" value="false" />
        <property name="hibernate.format_sql" value="false" />

        <!-- atualiza o banco, gera as tabelas se for preciso -->
        <property name="hibernate.hbm2ddl.auto" value="update" />
    </properties>

</persistence-unit>

Model Event

package com.eventos.eventos.models;

import java.io.Serializable;

import javax.persistence.Entity;

import javax.persistence.GeneratedValue;

import javax.persistence.GenerationType;

import javax.persistence.Id;

@Entity // Transforma essa classe em uma entidade no banco de dados
public class Evento implements Serializable {

    private static final long serialVersionUID = 1L;

    @Id // Transforma esse atributo no id da tabela
    @GeneratedValue(strategy = GenerationType.AUTO) // Faz com que esse atributo seja auto incrementado
    private long id;

    private String nome;
    private String local;
    private String data;
    private String horario;

    // Getters and Setters
    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    public String getNome() {
        return nome;
    }

    public void setNome(String nome) {
        this.nome = nome;
    }

    public String getLocal() {
        return local;
    }

    public void setLocal(String local) {
        this.local = local;
    }

    public String getData() {
        return data;
    }

    public void setData(String data) {
        this.data = data;
    }

    public String getHorario() {
        return horario;
    }

    public void setHorario(String horario) {
        this.horario = horario;
    }

}
    
asked by anonymous 08.03.2018 / 22:32

0 answers