-->
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.  [ 3 posts ] 
Author Message
 Post subject: Null foreing key
PostPosted: Fri Nov 18, 2005 11:53 am 
Newbie

Joined: Fri Nov 18, 2005 11:44 am
Posts: 6
Hibernate version:3

Hello all,
I need to have a one-to-many relation between 2 tables.
the "parent" table is:



Code:
    <class
        name="com.eaf.model.TemparioPartiDanno"
        table="atm_tempario_parti_danno"
        select-before-update="false"
        dynamic-update="true"
        dynamic-insert="true"
        optimistic-lock="all"
    >
      <id
            name="codTParteDanno"
            column="cod_t_parte_danno"
            type="java.lang.String"
            length="3"
         unsaved-value="undefined"
        >
            <generator class="assigned">
            </generator>
....
    </class>
</hibernate-mapping>


the "child":
Code:

<hibernate-mapping>
    <class
        name="com.eaf.model.AtmFattDettaglioCommesse"
        table="atm_fatt_dettaglio_commesse"
        select-before-update="false"
        dynamic-update="false"
        dynamic-insert="false"
        optimistic-lock="version"
    >
      <id
            name="idFattDettaglioCommesse"
            column="id_fatt_dettaglio_commesse"
            type="java.lang.Integer"
        >
            <generator class="increment">
            </generator>
        </id>
....

      </many-to-one>
    <!-- imported bi-directional many-to-one association to TemparioPartiDanno -->
      <many-to-one
         name="TemparioPartiDanno"
         class="com.eaf.model.TemparioPartiDanno"
            not-null="false"
         outer-join="auto"
      >   
         <column name="cod_t_parte_danno" />
      </many-to-one>

    </class>
</hibernate-mapping>

The problem occours when I set a NULL foreing key "cod_t_parte_danno"
I do have this Exception:



Code:
[eaf] DEBUG [http-8080-Processor24] AtmFattDettaglioCommesseDAOHibernate.saveAtmFattDettaglioCommesse(75) | atmFattDettaglioCommesse's id: 9
[eaf] ERROR [http-8080-Processor24] AbstractFlushingEventListener.performExecutions(277) | Could not synchronize database state with session
org.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing: com.eaf.model.TemparioPartiDanno
   at org.hibernate.engine.ForeignKeys.getEntityIdentifierIfNotUnsaved(ForeignKeys.java:216)
   at org.hibernate.type.EntityType.getIdentifier(EntityType.java:99)
   at org.hibernate.type.ManyToOneType.nullSafeSet(ManyToOneType.java:63)
   at org.hibernate.persister.entity.BasicEntityPersister.dehydrate(BasicEntityPersister.java:1617)
   at org.hibernate.persister.entity.BasicEntityPersister.update(BasicEntityPersister.java:1963)
   at org.hibernate.persister.entity.BasicEntityPersister.updateOrInsert(BasicEntityPersister.java:1909)
   at org.hibernate.persister.entity.BasicEntityPersister.update(BasicEntityPersister.java:2149)
   at org.hibernate.action.EntityUpdateAction.execute(EntityUpdateAction.java:75)
   at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:239)
   at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:223)
   at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:137)
   at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:274)
   at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)


Please help me! I tried ANYTHING, read ANY DOCUMENTATION, I really cannot figure out how to fix it!

please, please, please!
MANY thanks in advance for the answer

Francesco Ronchi


Top
 Profile  
 
 Post subject: Re: Null foreing key
PostPosted: Fri Nov 18, 2005 11:59 am 
Newbie

Joined: Fri Nov 18, 2005 11:44 am
Posts: 6
Of course I forgot to say: I need to set the property as NULL (this is a requirement). As an additional information I am using AppFuse as a framework.
Thanks again
Francesco


Top
 Profile  
 
 Post subject: Pethaps...
PostPosted: Sun Nov 20, 2005 10:35 am 
Newbie

Joined: Fri Nov 18, 2005 11:44 am
Posts: 6
can the problem come from the use of "saveOrUpdate()" method?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.