Não consigo gerar Tabelas com Hibernate em um projeto maven

05/12/2016

0

Olá pessoal , tenho um projeto maven e não consigo gerar as tabelas através do hibernate, ja mudei de banco e nada...


segue: hibernate.cgf.xml

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">

<hibernate-configuration>

<session-factory>

<!-- Configurações de Conexão com o Banco de Dados -->
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="connection.url">jdbc:mysql://localhost:3306/local</property>
<property name="connection.username">root</property>
<property name="connection.password">nmg230</property>

<!-- Pool de Conexões -->
<property name="connection.pool_size">1</property>

<!-- SQL dialect -->
<property name="dialect">org.hibernate.dialect.MySQL5InnoDBDialect</property>

<!-- Gerenciamento do Contexto das Sessões -->
<property name="current_session_context_class">thread</property>

<!-- Cache de Segundo Nível -->
<property name="cache.provider_class">org.hibernate.cache.internal.NoCacheProvider</property>

<!-- Mostra as SQLs Geradas -->
<property name="show_sql">true</property>

<!-- Cria as tabelas do banco de dados -->
<property name="hbm2ddl.auto">create</property>

<mapping class="br.com.flf.dominio.Cliente"/>
<mapping class="br.com.flf.dominio.ClientePF"/>
<mapping class="br.com.flf.dominio.ClientePJ"/>
<mapping class="br.com.flf.dominio.Endereco"/>
<mapping class="br.com.flf.dominio.Ordem_Serviço"/>
<mapping class="br.com.flf.dominio.Produto"/>
<mapping class="br.com.flf.dominio.Servico"/>
<mapping class="br.com.flf.dominio.Veiculo"/>

</session-factory>

</hibernate-configuration>


hibernate util:

package br.com.flf.util;

import org.hibernate.SessionFactory;
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.cfg.Configuration;
import org.hibernate.service.ServiceRegistry;

public class HibernateUtil {

private static SessionFactory fabricaDeSessoes = criarFabricaDeSessoes();

public static SessionFactory getFabricaDeSessoes() {
return fabricaDeSessoes;
}

private static SessionFactory criarFabricaDeSessoes() {
try {
Configuration configuracao = new Configuration().configure();
ServiceRegistry registro = new StandardServiceRegistryBuilder().applySettings(configuracao.getProperties())
.build();
SessionFactory fabrica = configuracao.buildSessionFactory(registro);
return fabrica;
} catch (Throwable ex) {
System.err.println("A fábrica de sessões não pode ser criada : " + ex);
throw new ExceptionInInitializerError(ex);
}
}

}


hibernate util teste:

package br.com.flf.util;

import org.hibernate.SessionFactory;
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.cfg.Configuration;
import org.hibernate.service.ServiceRegistry;

public class HibernateUtil {

private static SessionFactory fabricaDeSessoes = criarFabricaDeSessoes();

public static SessionFactory getFabricaDeSessoes() {
return fabricaDeSessoes;
}

private static SessionFactory criarFabricaDeSessoes() {
try {
Configuration configuracao = new Configuration().configure();
ServiceRegistry registro = new StandardServiceRegistryBuilder().applySettings(configuracao.getProperties())
.build();
SessionFactory fabrica = configuracao.buildSessionFactory(registro);
return fabrica;
} catch (Throwable ex) {
System.err.println("A fábrica de sessões não pode ser criada : " + ex);
throw new ExceptionInInitializerError(ex);
}
}

}


arquivo pom:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>br.com.flf</groupId>
<artifactId>flf</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>

<name>flf</name>
<url>http://maven.apache.org</url>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>

<!-- Commons Codes -->
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.10</version>
</dependency>

<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.10-FINAL</version>
</dependency>

<dependency>
<groupId>com.lowagie</groupId>
<artifactId>itext</artifactId>
<version>2.1.7</version>
</dependency>

<dependency>
<groupId>net.sf.jasperreports</groupId>
<artifactId>jasperreports</artifactId>
<version>6.2.0</version>
</dependency>

<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.4</version>
</dependency>

<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.4</version>
</dependency>

<dependency>
<groupId>org.webjars</groupId>
<artifactId>cryptojs</artifactId>
<version>3.1.2</version>
</dependency>

<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
<version>1.4.7</version>
</dependency>

<dependency>
<groupId>javax.activation</groupId>
<artifactId>activation</artifactId>
<version>1.1.1</version>
</dependency>

<dependency>
<groupId>eu.bitwalker</groupId>
<artifactId>UserAgentUtils</artifactId>
<version>1.20</version>
</dependency>

<!-- Servlet -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
</dependency>

<!-- PostgreSql -->
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>9.4.1209</version>
</dependency>


<!-- JUnit -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>

<!-- JSF -->
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.faces</artifactId>
<version>2.2.12</version>
</dependency>

<!-- OmniFaces -->
<dependency>
<groupId>org.omnifaces</groupId>
<artifactId>omnifaces</artifactId>
<version>1.11</version>
</dependency>

<!-- https://mvnrepository.com/artifact/org.webjars/bootstrap -->
<dependency>
<groupId>org.webjars</groupId>
<artifactId>bootstrap</artifactId>
<version>3.2.0</version>
</dependency>

<!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-core -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>5.2.5.Final</version>
</dependency>

<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId> <!-- DRIVER CONECTOR DO BANCO -->
<version>5.1.36</version>
</dependency>

</dependencies>
</project>


e uma das classes:

package br.com.flf.dominio;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;

@Entity
@SuppressWarnings("serial")
public class ClientePF extends Cliente implements Serializable {

@Id
@GeneratedValue( strategy = GenerationType.AUTO )
private Long codigo;

@Column(length=50, nullable=false)
private String nome;

private Date datanasc;

@Column(length=17, nullable=false)
private String cpf;

@Column(length=25)
private String rg;

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

public Date getDatanasc() {
return datanasc;
}
public void setDatanasc(Date datanasc) {
this.datanasc = datanasc;
}

public String getCpf() {
return cpf;
}
public void setCpf(String cpf) {
this.cpf = cpf;
}

public String getRg() {
return rg;
}
Vanilson Tavares

Vanilson Tavares

Responder

Posts

05/12/2016

Vanilson Tavares

Log:


dez 05, 2016 1:33:57 PM org.hibernate.Version logVersion
INFO: HHH000412: Hibernate Core {5.2.5.Final}
dez 05, 2016 1:33:57 PM org.hibernate.cfg.Environment <clinit>
INFO: HHH000206: hibernate.properties not found
dez 05, 2016 1:33:58 PM org.hibernate.annotations.common.reflection.java.JavaReflectionManager <clinit>
INFO: HCANN000001: Hibernate Commons Annotations {5.0.1.Final}
dez 05, 2016 1:33:58 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
WARN: HHH10001002: Using Hibernate built-in connection pool (not for production use!)
dez 05, 2016 1:33:58 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator
INFO: HHH10001005: using driver [com.mysql.jdbc.Driver] at URL [jdbc:mysql://localhost:3306/local]
dez 05, 2016 1:33:58 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator
INFO: HHH10001001: Connection properties: {user=root, password=****}
dez 05, 2016 1:33:58 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator
INFO: HHH10001003: Autocommit mode: false
dez 05, 2016 1:33:58 PM org.hibernate.engine.jdbc.connections.internal.PooledConnections <init>
INFO: HHH000115: Hibernate connection pool size: 1 (min=1)
dez 05, 2016 1:33:58 PM org.hibernate.dialect.Dialect <init>
INFO: HHH000400: Using dialect: org.hibernate.dialect.MySQL5InnoDBDialect
dez 05, 2016 1:33:59 PM org.hibernate.tool.schema.internal.SchemaCreatorImpl applyImportSources
INFO: HHH000476: Executing import script ''org.hibernate.tool.schema.internal.exec.ScriptSourceInputNonExistentImpl@15a34df2''
dez 05, 2016 1:34:00 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl stop
INFO: HHH10001008: Cleaning up connection pool [jdbc:mysql://localhost:3306/local]
Responder

22/07/2017

Jonatas Silva

Também estou com esse problema , se ja resolveu e quiser compartilhar.
Responder

22/06/2018

Oliveira

Também estou com esse problema , se ja resolveu e quiser compartilhar.
Responder

Utilizamos cookies para fornecer uma melhor experiência para nossos usuários, consulte nossa política de privacidade.

Aceitar