-->
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: Error doing a save
PostPosted: Fri Mar 02, 2012 4:29 am 
Newbie

Joined: Fri Mar 02, 2012 4:11 am
Posts: 1
Hello guys, i am newbie in hibernate and i am getting an error when teying to insert. I would apreciate some help.
I am using Hibernate 3.3

The error is:

object references an unsaved transient instance - save the transient instance before flushing: es.cyii.cyprehu.model.EstadoVO; nested exception is org.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing: es.cyii.cyprehu.model.EstadoVO

The idea is that a "ConsultaVO" can have a "EstadoVO" (Estate). The states are allready in the BBDD and it could be for example 1- Open, 2- Close.

I want to create a new Consulta in BBDD, without any Estate. then, after that, i want to be able to change the Estate to open, close, etc...
When i get a Consulta from BBDD, i want to recover the State, including the ID and the Description.

Probably i am making some things wrong.

The code is:

VOs:
Code:
public class ConsultaVO {
   
        private Long idConsulta;
        private EstadoVO estado;

       ...........getters and setters......
}

public class EstadoVO {

   private Long idEstado;
   private String descripcion;

         ...........getters and setters......
}


mappings
Code:
<class name="es.cyii.cyprehu.model.ConsultaVO" table="CONSULTAS">

      <id name="idConsulta" type="long">
         <column name="ID_CONSULTA"/>
                     <generator class="sequence">
                         <param name="sequence">seq_consultas</param>
                     </generator>
      </id>
         
         <many-to-one name="estado" column="ID_ESTADO"
         class="es.cyii.cyprehu.model.EstadoVO"
            lazy="false"/>      
</class>

<class name="es.cyii.cyprehu.model.EstadoVO" table="ESTADOS">

       <id name="idEstado" type="long">
             <column name="ID_ESTADO"/>
             <generator class="sequence">
                <param name="sequence">seq_estados</param>
             </generator>     
       </id>

      <property name="descripcion" type="string">
           <column name="DESCRIPCION"/>
      </property> 
      
</class>


DAO
Code:
public String insertConsulta (ConsultaVO consulta) throws Exception{
   
      String result;
      
      result = (String)getHibernateTemplate().save(consulta);
      
      return result;
      
   }


Any help please?
Thx you very much.


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.