Ajuda Hibernate + PostgreSQL

1 resposta
anunes

Não estou conseguindo fazer com que o hibernate crie as tabelas para mim.

hibernate.cfg.xml:
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
    "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
    "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<hibernate-configuration>

	<session-factory>

		<!-- Database connection settings -->
		<property name="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</property>
    	<property name="hibernate.connection.driver_class">org.postgresql.Driver</property>
    	<property name="hibernate.connection.url">jdbc:postgresql://localhost:5432/gs</property>
    	<property name="hibernate.connection.username">aldonunes</property>
    	<property name="hibernate.connection.password">123456</property>

		<property name="connection.pool_size">1</property>
		<property name="current_session_context_class">thread</property>
		<property name="cache.provider_class">
			org.hibernate.cache.NoCacheProvider
		</property>
		<property name="show_sql">true</property>
		<property name="format_sql">true</property>

		<mapping class="br.com.gs.domain.OrdemServico"/>
		<mapping class="br.com.gs.domain.Responsavel"/>
	</session-factory>

</hibernate-configuration>
ExportarBanco.java:
package br.com.gs.persistence;

import org.hibernate.cfg.AnnotationConfiguration;
import org.hibernate.cfg.Configuration;
import org.hibernate.tool.hbm2ddl.SchemaExport;

@SuppressWarnings("deprecation")
public class ExportarBanco {

	public static void main(String[] args) {
		AnnotationConfiguration anotacao = new AnnotationConfiguration();
		Configuration configuracao = anotacao.configure("hibernate.cfg.xml");
		SchemaExport exportar = new SchemaExport(configuracao);
		exportar.create(true,true);
		
	}
}
HibernateUtil.java:
package br.com.gs.persistence;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.AnnotationConfiguration;
import org.hibernate.cfg.Configuration;


@SuppressWarnings("deprecation")
public class HibernateUtil {
	private static Session sessao;	
	private static SessionFactory sessionFactory;

	static {
		Configuration configuracao = new AnnotationConfiguration().configure("hibernate.cfg.xml");
		sessionFactory = configuracao.buildSessionFactory();
	}
	
	public static SessionFactory getSessionFactory(){
		return sessionFactory;
	}
	
	public static Session getSessao() {
		return sessao;
	}

	public static void setSessao(Session sessao) {
		HibernateUtil.sessao = sessao;
	}
	
	
}
Console:
Jun 17, 2012 10:50:09 AM org.hibernate.annotations.common.Version <clinit>
INFO: HCANN000001: Hibernate Commons Annotations {4.0.1.Final}
Jun 17, 2012 10:50:09 AM org.hibernate.Version logVersion
INFO: HHH000412: Hibernate Core {4.1.1}
Jun 17, 2012 10:50:09 AM org.hibernate.cfg.Environment <clinit>
INFO: HHH000206: hibernate.properties not found
Jun 17, 2012 10:50:09 AM org.hibernate.cfg.Environment buildBytecodeProvider
INFO: HHH000021: Bytecode provider name : javassist
Jun 17, 2012 10:50:09 AM org.hibernate.cfg.Configuration configure
INFO: HHH000043: Configuring from resource: hibernate.cfg.xml
Jun 17, 2012 10:50:09 AM org.hibernate.cfg.Configuration getConfigurationInputStream
INFO: HHH000040: Configuration resource: hibernate.cfg.xml
Jun 17, 2012 10:50:09 AM org.hibernate.internal.util.xml.DTDEntityResolver resolveEntity
WARN: HHH000223: Recognized obsolete hibernate namespace http://hibernate.sourceforge.net/. Use namespace http://www.hibernate.org/dtd/ instead. Refer to Hibernate 3.6 Migration Guide!
Jun 17, 2012 10:50:09 AM org.hibernate.cfg.Configuration doConfigure
INFO: HHH000041: Configured SessionFactory: null

alguém saberia o motivo disso?

1 Resposta

ErickRAR

falta um Property

Criado 17 de junho de 2012
Ultima resposta 17 de jun. de 2012
Respostas 1
Participantes 2