-->
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.  [ 1 post ] 
Author Message
 Post subject: Another "save the transient instance before flushing: .
PostPosted: Sat Feb 19, 2005 6:35 pm 
Newbie

Joined: Sat Mar 13, 2004 9:46 am
Posts: 10
Hi all,

I don't know where to search anymore, read the forum messages but thery were not of any help. I have three tables: Order, Orderline and Ticket. An Order object have one or more Orderlines, an orderline have one Ticket and a Ticket may belong to one or more Orderlines.

Order -|-----n-< Orderline > -n------|- Ticket

After construction the persist objects I perform a save(Order), which results in the following exception:

Code:
object references an unsaved transient instance - save the transient instance before flushing: TickTicket
org.springframework.dao.InvalidDataAccessApiUsageException: object references an unsaved transient instance - save the transient instance before flushing: TickTicket
    at org.springframework.orm.hibernate.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:610)
    at org.springframework.orm.hibernate.HibernateTransactionManager.convertHibernateAccessException(HibernateTransactionManager.java:572)
    at org.springframework.orm.hibernate.HibernateTransactionManager.doCommit(HibernateTransactionManager.java:484)
    at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:377)
    at org.springframework.transaction.interceptor.TransactionAspectSupport.doCommitTransactionAfterReturning(TransactionAspectSupport.java:243)
    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:66)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:144)
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:174)
    at $Proxy0.saveOrder(Unknown Source)
    at com.lcmg.ticketing.business.order.impl.OrderServiceImplTest.testGetOrderCreator(OrderServiceImplTest.java:65)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)


Java code (using hibernate 2.1.8):

Code:
       TickOrderline tickOrderline = new TickOrderline();

        TickOrder tickOrder = new TickOrder();
        tickOrder.setTickOrderlines(new HashSet());
        tickOrder.getTickOrderlines().add(tickOrderline);
        tickOrderline.setTickOrder(tickOrder);

        TickTicket tickTicket = new TickTicket();
        tickTicket.setTickOrderlines(new HashSet());
        tickTicket.getTickOrderlines().add(tickOrderline);
        tickOrderline.setTickTicket(tickTicket);


Mapping files:

Code:
---
<class
    name="TickOrder"
    table="tick_order"
>

    <id
        name="id"
        type="java.lang.String"
        column="id"
    >
        <generator class="uuid.hex" />
    </id>
   ...
    <set
        name="tickOrderlines"
        lazy="true"
        inverse="true"
      cascade="save-update"
    >
        <key>
            <column name="tick_order_id" />
        </key>
        <one-to-many
            class="TickOrderline"
        />
    </set>
...
</class>


Code:
<class
    name="TickOrderline"
    table="tick_orderline"
>

    <id
        name="id"
        type="java.lang.String"
        column="id"
    >
        <generator class="uuid.hex" />
    </id>

    <many-to-one
        name="tickOrder"
        class="TickOrder"
        not-null="true"
    >
        <column name="tick_order_id" />
    </many-to-one>
   
    <many-to-one
        name="tickTicket"
        class="TickTicket"
        not-null="true"
    >
        <column name="tick_ticket_id" />
    </many-to-one>
...
</class>


Code:
<class
    name="TickTicket"
    table="tick_ticket"
>

    <id
        name="id"
        type="java.lang.String"
        column="id"
    >
        <generator class="uuid.hex" />
    </id>

    <set
        name="tickOrderlines"
        lazy="true"
        inverse="true"
      cascade="save-update"
    >
        <key>
            <column name="tick_ticket_id" />
        </key>
        <one-to-many
            class="TickOrderline"
        />
    </set>
...
</class>



What did I wrong?


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

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.