Pessoal, blz?! Estou iniciando no Hibernate e criei um projeto pequeno, só com uma tabela pra testar o framework.
Li vários tópicos relacionados a problemas no Hibernate, mas não achei nenhum que auxiliasse.
Estou tendo o seguinte erro:
22/01/2009 14:25:04 org.hibernate.cfg.Environment <clinit>
INFO: Hibernate 3.2.5
22/01/2009 14:25:04 org.hibernate.cfg.Environment <clinit>
INFO: hibernate.properties not found
22/01/2009 14:25:04 org.hibernate.cfg.Environment buildBytecodeProvider
INFO: Bytecode provider name : cglib
22/01/2009 14:25:04 org.hibernate.cfg.Environment <clinit>
INFO: using JDK 1.4 java.sql.Timestamp handling
22/01/2009 14:25:04 org.hibernate.cfg.Configuration configure
INFO: configuring from resource: /hibernate.cfg.xml
22/01/2009 14:25:04 org.hibernate.cfg.Configuration getConfigurationInputStream
INFO: Configuration resource: /hibernate.cfg.xml
org.hibernate.HibernateException: /hibernate.cfg.xml not found
********* Erro na classe StartHibernate ***********
at org.hibernate.util.ConfigHelper.getResourceAsStream(ConfigHelper.java:147)
at org.hibernate.cfg.Configuration.getConfigurationInputStream(Configuration.java:1405)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1427)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1414)
at modelo.StartHibernate.<clinit>(StartHibernate.java:16)
at controle.Controle.main(Controle.java:25)
Exception in thread "main" java.lang.NullPointerException
at modelo.StartHibernate.getSession(StartHibernate.java:26)
at controle.Controle.main(Controle.java:25)
Java Result: 1
Diz que não há o arquivo .properties, como eu crio esse arquivo e onde ele fica?
Essa é a classe que cria os objetos de sessão de onde surge o erro:package modelo;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
public class StartHibernate {
private static SessionFactory factory;
static{
try{
factory = new Configuration().configure().buildSessionFactory();
}
catch(Exception e){
System.out.println("********* Erro na classe StartHibernate ***********");
e.printStackTrace();
factory = null;
}
}
public static Session getSession(){
return factory.openSession();
}
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="modelo.Usuario" table="usuario">
<id name="id">
<generator class="increment"/>
</id>
<property name="name"/>
<property name="login"/>
<property name="pass"/>
</class>
</hibernate-mapping>
<?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>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/paroquia</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.connection.password">123</property>
<mapping class="modelo.Usuario" package="modelo"/>
<mapping resource="Usuario.hbm.xml"/>
<!-- Condiguração do c3p0 -->
<property name="hibernate.c3p0.max_size">10</property>
<property name="hibernate.c3p0.min_size">2</property>
<property name="hibernate.c3p0.timeout">5000</property>
<property name="hibernate.c3p0.max_statements">10</property>
<property name="hibernate.c3p0.idle_test_period">3000</property>
<property name="hibernate.c3p0.acquire_increment">2</property>
<!-- Configurações de debug -->
<property name="show_sql">true</property>
<property name="use_outer_join">true</property>
<property name="hibernate.generate_statistics">true</property>
<property name="hibernate.use_sql_comments">true</property>
</session-factory>
Hibernate - antlr-2.7.6.jar
Hibernate - asm.jar
Hibernate - asm-attrs.jar
Hibernate - cglib-2.1.3.jar
Hibernate - commons-collections2.1.1.jar
Hibernate - commons-logging-1.1.jar
Hibernate - dom4j-1.6.1.jar
Hibernate - ehcache-1.2.3.jar
Hibernate - jdbc2_0-stdext.jar
Hibernate - jta.jar
Hibernate - hibernate3.jar
Hibernate - hibernate-tools.jar
Hibernate - hibernate-annotations.jar
Hibernate - hibernate-commons-annotations.jar
Hibernate - hibernate-entitymanager.jar
Hibernate - javassist.jar
Persistence - ejb3-persistence.jar
mysql-connector-java-5.1.6-bin.jar
jdk1.6
