Boa tarde!!
Pessoal, estou desenvolvendo uma aplicação teste para entender o hibernate, porém estou tendo alguns problemas.
Erro
31 [main] INFO org.hibernate.cfg.Environment - Hibernate 3.3.1.GA
47 [main] INFO org.hibernate.cfg.Environment - hibernate.properties not found
63 [main] INFO org.hibernate.cfg.Environment - Bytecode provider name : javassist
63 [main] INFO org.hibernate.cfg.Environment - using JDK 1.4 java.sql.Timestamp handling
156 [main] INFO org.hibernate.cfg.Configuration - Reading mappings from resource: Amigo.hbm.xml
156 [main] INFO org.hibernate.cfg.Configuration - Reading mappings from resource: Amigo.hbm.xml
391 [main] INFO org.hibernate.cfg.HbmBinder - Mapping class: br.com.urano.HibernateExemplo.Amigo -> amigos
500 [main] WARN org.hibernate.connection.UserSuppliedConnectionProvider - No connection properties specified - the user must supply JDBC connections
org.hibernate.HibernateException: Hibernate Dialect must be explicitly set
at org.hibernate.dialect.DialectFactory.determineDialect(DialectFactory.java:80)
Estou utilizando Postgres
TABELA amigos
nome character varying(40) NOT NULL DEFAULT ‘’::character varying,
endereco character varying(60) NOT NULL DEFAULT ‘’::character varying,
fone character varying(11) DEFAULT NULL::character varying,
cel character varying(11) DEFAULT NULL::character varying,
email character varying(70) DEFAULT NULL::character varying,
nascimento date,
CONSTRAINT amigos_pkey PRIMARY KEY (nome)
HIBERNATE.PROPERTIES.XML
hibernate.dialect = org.hibernate.dialect.PostgreSQLDialect
hibernate.connection.username = xxx
hibernate.connection.password = uxxx
hibernate.connection.driver_class = org.postgresql.Driver
hibernate.connection.url = jdbc:postgresql://localhost:5432/TesteHibernate
hibernate.hbm2ddl.auto=update
HIBERNATE.CFG.XML
AMIGO.HBM.XML
<?xml version="1.0"?>public class Amigo {
aqui esta os setters and getters
}
import java.util.List;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
import org.hibernate.classic.Session;
public class AmigoDao {
private SessionFactory factory;
public AmigoDao() throws Exception {
factory = new Configuration().addClass(Amigo.class)
.buildSessionFactory();
}
public void insert(Amigo amigo) throws Exception {
Session session = factory.openSession();
session.save(amigo);
session.flush();
session.close();
}
public java.util.List getList(String condicao) throws Exception {
Session session = factory.openSession();
List amigos = session.find(condicao);
session.flush();
session.close();
return amigos;
}
public Amigo retrieve(String pk) throws Exception {
Session session = factory.openSession();
Amigo amigo = (Amigo) session.load(Amigo.class, pk);
session.flush();
session.close();
return amigo;
}
public void delete(Amigo amigo) throws Exception {
Session session = factory.openSession();
session.delete(amigo);
session.flush();
session.close();
}
}
public class TesteAmigo {
public static void main(String[] args) throws Exception {
try {
Amigo amigo = new Amigo();
amigo.setNome("seu nome");
amigo.setEndereco("seu endereco");
amigo.setTelefone("seu fone");
amigo.setCelular("seu celular");
amigo.setEmail("seu mail");
// amigo.setNascimento("data do tipo Date");
AmigoDao dao = new AmigoDao();
dao.insert(amigo);
} catch (Exception e) {
e.printStackTrace();
}
}
}
Alguem consegue identificar o problema?