-->
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: Problems with one-to-many asociations
PostPosted: Tue Jun 13, 2006 3:43 am 
Newbie

Joined: Mon May 29, 2006 6:07 am
Posts: 12
Hello! I´ve got problems updating a list, the mappings:
Code:
<class name="model.Departamento" table="Departamento" >
        <id name="departamento_id" column="departamento_id">
            <generator class="increment"/>
        </id>
       
        <property name="descripcion" type="string"/>
        <property name="nombre" type="string"/>
       
        <list name="puestos" cascade="all" lazy="false">
                   <key column="departamento_id"/>
         <index column="puesto_id"/>
         <one-to-many class="model.Puesto"/>
        </list>
    </class>


Code:
<class name="model.Puesto" table="Puesto">
        <id name="puesto_id" column="puesto_id">
            <generator class="increment"/>
        </id>
       
        <property name="descripcion" type="string"/>
        <property name="nombre" type="string"/>
       
        <list name="permisos">
           <key column="puesto_id"/>
         <index column="permiso_id"/>
         <one-to-many class="model.Permiso"/>
        </list>
    </class>


I thinks, the mappings are ok, but when i try to di something like this:

Code:
session.beginTransaction();
Puesto pto=initPuesto(PForm);            
Departamento depto=(Departamento)session.get("model.Departamento",Form.getId());
depto.addPuesto(pto);
session.update(depto);
session.getTransaction().commit();
session.close();


this code throws the exception:
Code:
java.sql.BatchUpdateException: Duplicate entry '0' for key 1
   at com.mysql.jdbc.ServerPreparedStatement.executeBatch(ServerPreparedStatement.java:647)
   at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:58)
   at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:195)


have any idea? thanks a lot


Top
 Profile  
 
 Post subject: possible bug
PostPosted: Tue Jun 13, 2006 4:02 am 
Newbie

Joined: Mon May 29, 2006 6:07 am
Posts: 12
I tried the same, change the list for set, and it works. but i need to do with a list. It´s possible a new bug?


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.