-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: null id in entry
PostPosted: Tue Apr 05, 2005 10:08 am 
Beginner
Beginner

Joined: Tue Dec 21, 2004 11:53 am
Posts: 42
Read the rules before posting!
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:
2.1.6
Mapping documents:
<hibernate-mapping
>
<class
name="com.araujo.convenios.model.persistence.autorizacaovenda.AutorizacaoVenda"
table="AUTORIZACAO_VENDA"
dynamic-update="false"
dynamic-insert="false"
select-before-update="false"
optimistic-lock="version"
>

<id
name="codigo"
column="ATVE_CD_AUTORIZACAO"
type="java.lang.Integer"
>
<generator class="identity">
<!--
To add non XDoclet generator parameters, create a file named
hibernate-generator-params-AutorizacaoVenda.xml
containing the additional parameters and place it in your merge dir.
-->
</generator>
</id>

<property
name="abateSaldoFinanceiro"
type="com.araujo.convenios.model.enum.SimNaoEnum"
update="true"
insert="true"
access="property"
column="ATVE_FL_ABATE_SALDO_FINANC"
/>

<property
name="abateSaldoQuantidade"
type="com.araujo.convenios.model.enum.SimNaoEnum"
update="true"
insert="true"
access="property"
column="ATVE_FL_ABATE_SALCO_QTDE"
/>

<property
name="dataFechamento"
type="java.util.Calendar"
update="true"
insert="true"
access="property"
column="ATVE_DT_FECHAMENTO"
/>

<property
name="dataInclusao"
type="java.util.Calendar"
update="true"
insert="true"
access="property"
column="ATVE_DT_INCLUSAO"
/>

<property
name="dataLiberacao"
type="java.util.Calendar"
update="true"
insert="true"
access="property"
column="ATVE_DT_LIBERACAO"
/>

<property
name="dataValidade"
type="java.util.Calendar"
update="true"
insert="true"
access="property"
column="ATVE_DT_VALIDADE"
/>

<many-to-one
name="empresa"
class="com.araujo.convenios.model.persistence.empresa.Empresa"
cascade="none"
outer-join="auto"
update="true"
insert="true"
access="property"
column="EMPR_CD_EMPRESA"
/>

<many-to-one
name="loja"
class="com.araujo.convenios.model.persistence.loja.Loja"
cascade="none"
outer-join="auto"
update="true"
insert="true"
access="property"
column="FILI_CD_FILIAL"
/>

<many-to-one
name="medico"
class="com.araujo.convenios.model.persistence.medico.Medico"
cascade="none"
outer-join="auto"
update="true"
insert="true"
access="property"
>
<column
name="MEDI_CD_CRM"
/>
<column
name="MEDI_SG_UF_CRM"
/>
<column
name="MEDI_TP_PRESCRITOR"
/>
</many-to-one>

<property
name="numeroCid"
type="java.lang.String"
update="true"
insert="true"
access="property"
column="ATVE_NR_CID"
/>

<property
name="numeroDocumento"
type="java.lang.String"
update="true"
insert="true"
access="property"
column="ATVE_NR_DOCUMENTO"
/>

<property
name="numeroOrdemCompra"
type="java.lang.String"
update="true"
insert="true"
access="property"
column="ATVE_NR_ORDEM_COMPRA"
/>

<property
name="numeroReceita"
type="java.lang.String"
update="true"
insert="true"
access="property"
column="ATVE_NR_RECEITA"
/>

<property
name="tipoAutorizacao"
type="com.araujo.convenios.model.enum.SituacaoAutorizacaoEnum"
update="true"
insert="true"
access="property"
column="ATVE_TP_AUTORIZACAO"
/>

<many-to-one
name="tipoDocumento"
class="com.araujo.convenios.model.persistence.tipodocumento.TipoDocumento"
cascade="none"
outer-join="auto"
update="true"
insert="true"
access="property"
column="TIDO_CD_DOCUMENTO"
/>

<property
name="tipoSituacao"
type="com.araujo.convenios.model.enum.SituacaoAutorizacaoEnum"
update="true"
insert="true"
access="property"
column="ATVE_TP_SITUACAO"
/>

<many-to-one
name="usuarioAutorizacao"
class="com.araujo.convenios.model.persistence.usuario.Usuario"
cascade="none"
outer-join="auto"
update="true"
insert="true"
access="property"
column="USUA_CD_USUARIO_AUTORIZ"
/>

<many-to-one
name="usuarioPreAutorizacao"
class="com.araujo.convenios.model.persistence.usuario.Usuario"
cascade="none"
outer-join="auto"
update="true"
insert="true"
access="property"
column="USUA_CD_USUARIO_PRE_AUTORIZ"
/>

<property
name="valorOrdemCompra"
type="java.lang.Double"
update="true"
insert="true"
access="property"
column="ATVE_VL_ORDEM_COMPRA"
/>

<property
name="valorTotal"
type="java.lang.Double"
update="true"
insert="true"
access="property"
column="ATVE_VL_TOTAL"
/>

<many-to-one
name="vidaComprador"
class="com.araujo.convenios.model.persistence.vida.Vida"
cascade="none"
outer-join="auto"
update="true"
insert="true"
access="property"
column="VIDA_CD_VIDA_COMPRADOR"
/>

<many-to-one
name="vidaReceita"
class="com.araujo.convenios.model.persistence.vida.Vida"
cascade="none"
outer-join="auto"
update="true"
insert="true"
access="property"
column="VIDA_CD_VIDA_RECEITA"
/>

<set
name="itensAutorizacaoVenda"
lazy="false"
inverse="false"
cascade="all-delete-orphan"
sort="unsorted"
>

<key
column="ATVE_CD_AUTORIZACAO"
>
</key>

<one-to-many
class="com.araujo.convenios.model.persistence.itemautorizacaovenda.ItemAutorizacaoVenda"
/>

</set>

<!--
To add non XDoclet property mappings, create a file named
hibernate-properties-AutorizacaoVenda.xml
containing the additional properties and place it in your merge dir.
-->

</class>

</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
public Serializable insert(Entity obj) throws PersistenceException {
Session session = getCurrentSession();
beginTransaction();
Serializable s = null;
try {
s = session.save(obj);
} catch (HibernateException e) {
logger.error(e);
rollbackTransaction();
throw new PersistenceException(e);
} finally {
commitTransaction();
closeSession();
}
return s;
}
//getCurrentSession is implemented like Hibernate in action Thread local
Full stack trace of any exception that occurs:
11:03:39,823 ERROR [AssertionFailure] an assertion failure occured (this may indicate a bug in Hibernate, but is more likely due to unsafe use of the session)
net.sf.hibernate.AssertionFailure: null id in entry (don't flush the Session after an exception occurs)
at net.sf.hibernate.impl.SessionImpl.checkId(SessionImpl.java:2641)
at net.sf.hibernate.impl.SessionImpl.flushEntity(SessionImpl.java:2465)
at net.sf.hibernate.impl.SessionImpl.flushEntities(SessionImpl.java:2458)
at net.sf.hibernate.impl.SessionImpl.flushEverything(SessionImpl.java:2260)
at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2239)
at net.sf.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:61)
at com.araujo.convenios.util.dao.HibernateUtil.commitTransaction(HibernateUtil.java:93)
at com.araujo.convenios.util.dao.HibernateDAO.commitTransaction(HibernateDAO.java:131)
at com.araujo.convenios.util.dao.HibernateDAO.insert(HibernateDAO.java:47)
at com.araujo.convenios.eai.dao.test.autorizacaovenda.HibernateAutorizacaoVendaDAOTest.testInsert(HibernateAutorizacaoVendaDAOTest.java:113)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:421)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:305)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:186)
Name and version of the database you are using:

The generated SQL (show_sql=true):
Hibernate: insert into AUTORIZACAO_VENDA (ATVE_FL_ABATE_SALDO_FINANC, ATVE_FL_ABATE_SALCO_QTDE, ATVE_DT_FECHAMENTO, ATVE_DT_INCLUSAO, ATVE_DT_LIBERACAO, ATVE_DT_VALIDADE, EMPR_CD_EMPRESA, FILI_CD_FILIAL, MEDI_CD_CRM, MEDI_SG_UF_CRM, MEDI_TP_PRESCRITOR, ATVE_NR_CID, ATVE_NR_DOCUMENTO, ATVE_NR_ORDEM_COMPRA, ATVE_NR_RECEITA, ATVE_TP_AUTORIZACAO, TIDO_CD_DOCUMENTO, ATVE_TP_SITUACAO, USUA_CD_USUARIO_AUTORIZ, USUA_CD_USUARIO_PRE_AUTORIZ, ATVE_VL_ORDEM_COMPRA, ATVE_VL_TOTAL, VIDA_CD_VIDA_COMPRADOR, VIDA_CD_VIDA_RECEITA) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
Debug level Hibernate log excerpt:

Well, I'm kida lost with this. This is happing during a test case (non-managed configuration of SessionFactory). It happens only for this specific class mapping, all other test cases that includes transactional methods (insert,update,delete) works fine.
Any ideas of what could be this?

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 05, 2005 1:12 pm 
Beginner
Beginner

Joined: Tue Dec 21, 2004 11:53 am
Posts: 42
:Well wasn't a problem :P

First I had a wrong classname for an enum property, and second, I had my composite key with one of the properties null.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.