Erro na clasee aluno.hbm.xml

5 respostas
W

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

run:
13/09/2011 22:33:16 org.hibernate.cfg.Environment
INFO: Hibernate 3.2.5
13/09/2011 22:33:16 org.hibernate.cfg.Environment
INFO: hibernate.properties not found
13/09/2011 22:33:16 org.hibernate.cfg.Environment buildBytecodeProvider
INFO: Bytecode provider name : cglib
13/09/2011 22:33:16 org.hibernate.cfg.Environment
INFO: using JDK 1.4 java.sql.Timestamp handling
13/09/2011 22:33:16 org.hibernate.cfg.Configuration configure
INFO: configuring from resource: /hibernate.cfg.xml
13/09/2011 22:33:16 org.hibernate.cfg.Configuration getConfigurationInputStream
INFO: Configuration resource: /hibernate.cfg.xml
13/09/2011 22:33:16 org.hibernate.cfg.Configuration addResource
INFO: Reading mappings from resource : aluno.hbm.xml
13/09/2011 22:33:16 org.hibernate.util.XMLHelper$ErrorLogger error

5 Respostas

andreiribas

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

run:
13/09/2011 22:33:16 org.hibernate.cfg.Environment
INFO: Hibernate 3.2.5
13/09/2011 22:33:16 org.hibernate.cfg.Environment
INFO: hibernate.properties not found
13/09/2011 22:33:16 org.hibernate.cfg.Environment buildBytecodeProvider
INFO: Bytecode provider name : cglib
13/09/2011 22:33:16 org.hibernate.cfg.Environment
INFO: using JDK 1.4 java.sql.Timestamp handling
13/09/2011 22:33:16 org.hibernate.cfg.Configuration configure
INFO: configuring from resource: /hibernate.cfg.xml
13/09/2011 22:33:16 org.hibernate.cfg.Configuration getConfigurationInputStream
INFO: Configuration resource: /hibernate.cfg.xml
13/09/2011 22:33:16 org.hibernate.cfg.Configuration addResource
INFO: Reading mappings from resource : aluno.hbm.xml
13/09/2011 22:33:16 org.hibernate.util.XMLHelper$ErrorLogger error

Você tem que fechar o elemento id:

W

Boa tarde andreribas,

Entendi, mas e aquele que está depois da linha property name=“alu_curso”/> não faz parte do id acima.

Muito obrigado,

Elcio

andreiribas

webelcio:
Boa tarde andreribas,

Entendi, mas e aquele que está depois da linha property name=“alu_curso”/> não faz parte do id acima.

Muito obrigado,

Elcio

Não, o id deve terminar ali.

<hibernate-mapping> 
<class name="Aluno" table="alunos"> 
<id name="alu_codigo" column="alu_codigo" type="int" /> 

<property name="alu_nome"/> 
<property name="alu_cidade"/> 
<property name="alu_fone"/> 
<property name="alu_curso"/> 

</class> 
</hibernate-mapping>
W

Valeu meu amigo,

Vou testar e qualquer coisa volto a falar,

Muito obrigado,

Elcio

W

Bom dia Andreiribas e quem possa me ajudar,
O código do aluno.hbm.xml você já tem. Esse abaixo é o do GravaAluno

[// Aluno Elcio Balieiro Pinto

import javax.swing.<em>;

import org.hibernate.</em>;

import org.hibernate.cfg.*;
public class GravaAluno

{

public static void main (String [] args)

{

try

{

SessionFactory fabrica = new Configuration().configure().buildSessionFactory();

Session sessao = fabrica.openSession();

Aluno aluno = new Aluno();

aluno.setAlu_codigo(1);

aluno.setAlu_nome=(Elcio Balieiro Pinto);

aluno.setAlu_curso=(Hibernate);

aluno.setAlu_fone=([telefone removido]);

aluno.setAlu_cidade=(Porto Real);

Transaction tx_aluno = sessao.beginTransaction();

sessao.save(aluno);

tx_aluno.commit();

sessao.close();

}

catch(Exception erro)

{

JOptionPane.showMessageDialog(null,"Erro na inserção : "+erro);

}

}

}
]

Segue a mensagem de erro que apareceu ao compilar o arquivo:

run:
Hibernate: insert into alunos (alu_nome, alu_cidade, alu_fone, alu_curso, alu_codigo) values (?, ?, ?, ?, ?)
CONSTRUÍDO COM SUCESSO (tempo total: 2 segundos)

No banco de dados do Postgre aparece somente o código e o restante dos dados dos outros atributos não aparecem

Certo de contar com sua ajuda,

Muito obrigado,

Elcio

Criado 14 de setembro de 2011
Ultima resposta 15 de set. de 2011
Respostas 5
Participantes 2