Bom, sou um iniciante no Hibertate e não estou conseguindo fazê-lo funcionar, já tentei um milhão de vezes e um milhão de alternativas e nada de resolver
Vou postar os erros
90 [main] INFO org.hibernate.annotations.common.Version - Hibernate Commons Annotations 3.2.0.Final
96 [main] INFO org.hibernate.cfg.Environment - Hibernate 3.6.1.Final
97 [main] INFO org.hibernate.cfg.Environment - hibernate.properties not found
100 [main] INFO org.hibernate.cfg.Environment - Bytecode provider name : javassist
103 [main] INFO org.hibernate.cfg.Environment - using JDK 1.4 java.sql.Timestamp handling
145 [main] INFO org.hibernate.cfg.Configuration - configuring from resource: /hibernate.cfg.xml
145 [main] INFO org.hibernate.cfg.Configuration - Configuration resource: /hibernate.cfg.xml
190 [main] ERROR org.hibernate.util.XMLHelper - Error parsing XML: /hibernate.cfg.xml(2) The processing instruction target matching "[xX][mM][lL]" is not allowed.
minha classe de persicistencia é essa:
package java_hibernate;
import javax.swing.*;
import org.hibernate.*;
import org.hibernate.cfg.*;
public class Aluno_Persistencia {
public static void main(String []args)
{
try
{
SessionFactory buildSession = new Configuration().configure().buildSessionFactory();
Session session = buildSession.openSession();
Aluno newStudent = new Aluno();
newStudent.setId_codigo(1);
newStudent.setNome_aluno("Guilherme Santiago");
newStudent.setCidade_aluno("Matutina");
newStudent.setTelefone_aluno("09870988");
newStudent.setCurso("Sistemas de Informação");
Transaction set_Aluno = session.beginTransaction();
session.save(newStudent);
set_Aluno.commit();
session.clear();
}catch(Exception error){
JOptionPane.showMessageDialog(null, "Erro na inserção: "+error);
}
}
}
minha Aluno.hbm.xml
<?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="Aluno" table="alunos">
<id name="id-aluno" type="integer" column="id_aluno" >
<generator class="assigned"/>
</id>
<property name="nome_Aluno">
<column name="nome_Aluno" />
</property>
<property name="cidade_Aluno">
<column name="cidade_Aluno"/>
</property>
<property name="telefone_Aluno">
<column name="telefone_Aluno"/>
</property>
<property name="curso">
<column name="curso"/>
</property>
</class>
</hibernate-mapping>
e minha hibernate.cfg.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.driver_class">org.postgresql.Driver</property>
<property name="hibernate.connection.url">jdbc:postgresql://localhost:5432/javaHibernate</property>
<property name="hibernate.connection.username">postgres</property>
<property name="hibernate.connection.password">crazyforher</property>
<property name="dialect">org.hibernate.dialect.PostgreSQLDialect</property>
<!-- Mapping files -->
<mapping resource="Aluno.hbm.xml"/>
</session-factory>
</hibernate-configuration>
desde já agradeço