Hibernate

Oi

estou tentando salvar dados na tabela, quando salvo no hibernate ele não da erro, mas tambem não salva, alguem sabe o que pode estar acontecendo.

[code] Pessoa p = new Pessoa();
p.setEmail("m@teste.com.br");
p.setId(new Integer(1));
p.setNome("Marci");
p.setTelefone("337-5196");
sessao.save(p);
sessao.flush();

        transaction.commit();//Finalizando a transação
        sessao.close();//Fechando a sessão[/code]

XML pessoa

[code] <?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>

&lt;class name=&quot;Pessoa&quot;&gt;

	&lt;!--Identificador da classe --&gt;

	&lt;id name=&quot;id&quot;&gt;
	    &lt;generator class=&quot;increment&quot;/&gt;
	&lt;/id&gt;


	&lt;!--Propriedades da classe --&gt;

	&lt;property name=&quot;nome&quot;/&gt;
	&lt;property name=&quot;telefone&quot;/&gt;
	&lt;property name=&quot;email&quot;/&gt;

	

&lt;/class&gt;

</hibernate-mapping>[/code]

Obrigada,
Marci :???:

Ta faltando vc informar os campos da tabelae e a tabela !!

assim:

 &lt;class name=&quot;Pessoa&quot; table=&quot;PESSOA&quot;&gt; 

     &lt;property name=&quot;nome&quot; 	column=&quot;NOME&quot;	/&gt; 

Valeu AndersonAugusto, mas ai tah certo, não preciso colocar o nome da tabela porque o nome da classe ja eh igual ao nome da tabela, outra coisa que pude perceber eh que se eu tentar acessar o banco de dados durante a execução do meu programa ele não permite eh claro!!, mas salva os dados, parece que tem uma interferencia…sei lahh, parece que deve ser problemas de conexão …ainda não descobri…mas valeu a dica

Marci :slight_smile:

Que banco vc usa?

uso hsqldb, não posso trocar tem que ser este…estranho que hoje de manhã eu estava conseguindo salvar…ai troquei algumas coisas…que dai então não funcionava mais nada, voltei ao que tava antes…e agora soh salva com essa loucura de acessar o banco no meio da execução do programa.

Marci

descobri qual é o erro, estou esquecendo de dar um shutdown no banco, mas agora a duvida eh a seguinte:

configurei as conexões em um arquivo de mapeamento, afinal estou usando hibernate…então como faço p shutdown no banco sem usar comando sql tipo statement…
arquivo de mapeamento xml:

[code]<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<hibernate-configuration>

&lt;session-factory&gt;

	&lt;property name=&quot;hibernate.dialect&quot;&gt; 
		org.hibernate.dialect.HSQLDialect 
        &lt;/property&gt; 

	&lt;property name=&quot;hibernate.connection.driver_class&quot;&gt; 
			org.hsqldb.jdbcDriver 
        &lt;/property&gt; 

	&lt;property name=&quot;hibernate.connection.url&quot;&gt; 
			jdbc&#58;hsqldb&#58;Banco
	&lt;/property&gt; 	

	&lt;property name=&quot;hibernate.connection.username&quot;&gt; 
		sa
	&lt;/property&gt; 
	
	&lt;property name=&quot;hibernate.connection.password&quot;&gt;
	&lt;/property&gt;


 	&lt;!--Condiguração do c3p0 --&gt;

	&lt;property name=&quot;hibernate.c3p0.max_size&quot;&gt;10&lt;/property&gt;
	&lt;property name=&quot;hibernate.c3p0.min_size&quot;&gt;2&lt;/property&gt; 
	&lt;property name=&quot;hibernate.c3p0.timeout&quot;&gt;5000&lt;/property&gt;
	&lt;property name=&quot;hibernate.c3p0.max_statements&quot;&gt;10&lt;/property&gt;
	&lt;property name=&quot;hibernate.c3p0.idle_test_period&quot;&gt;3000&lt;/property&gt;
	&lt;property name=&quot;hibernate.c3p0.acquire_increment&quot;&gt;2&lt;/property&gt;



	&lt;!--Configurações de debug --&gt;

	&lt;property name=&quot;show_sql&quot;&gt;true&lt;/property&gt; 
	&lt;property name=&quot;hibernate.generate_statistics&quot;&gt;true&lt;/property&gt; 
	&lt;property name=&quot;hibernate.use_sql_comments&quot;&gt;true&lt;/property&gt;

	&lt;mapping resource=&quot;Curso.hbm.xml&quot;/&gt; 
	&lt;mapping resource=&quot;Disciplina.hbm.xml&quot;/&gt;
	&lt;mapping resource=&quot;Turma.hbm.xml&quot;/&gt; 
	&lt;mapping resource=&quot;Pessoa.hbm.xml&quot;/&gt; 
	&lt;mapping resource=&quot;Aluno.hbm.xml&quot;/&gt;
	&lt;mapping resource=&quot;Professor.hbm.xml&quot;/&gt;
	&lt;mapping resource=&quot;Endereco.hbm.xml&quot;/&gt;

&lt;/session-factory&gt; 

</hibernate-configuration>[/code]

Marci :?:

Muito o estranho Marci…

Vc precisa dar shutdown no banco para efetivar as alterações?

preciso, senão ele não persiste os dados, não consegui fazer comando com o hibernate p fechar a conexão, então usei comandos sql mesmo…por enquanto tah funcionando…

Marci :razz: