-->
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: hbm to Annotation > @OneToMany Unidireccional
PostPosted: Fri Jul 27, 2012 10:32 am 
Newbie

Joined: Mon Oct 19, 2009 4:33 pm
Posts: 8
This works perfectly, but I cant do the same with @Annotations
AfiliadoDiscapacitado [1]----->[1..*] AfiliadoDDM

Code:
        <list name="afiliadoDDMList" table="afiliado_ddm" inverse="false" cascade="all" lazy="false" fetch="select">
            <key column="afiliado_discapacitado_id" />
            <index column="id"/>
            <one-to-many class="modelo.AfiliadoDDM"/>
        </list>



the closer I was to get it is this:
Code:
    @JoinTable(name = "afiliado_ddm"
        , joinColumns = @JoinColumn(name = "afiliado_discapacitado_id")
        , inverseJoinColumns = @JoinColumn(name = "id")
    )
    @OneToMany(cascade = CascadeType.ALL)
    private List<AfiliadoDDM> afiliadoDDMList;


but the SQL insert is not correct:
Caused by: java.sql.BatchUpdateException: Batch entry 0 insert into afiliado_ddm (afiliado_discapacitado_id, id) values ('6', '7') was aborted. Call getNextException to see the cause.

it should be inserting 4 entities and afiliado_discapacitado_id because..
Code:
<hibernate-mapping>
    <class name="modelo.AfiliadoDDM" table="afiliado_ddm" schema="public">
        <id name="id" type="integer">
            <column name="id" />
            <generator class="identity" />
        </id>
        <many-to-one name="discapacidadesGradoGravedad" class="modelo.DiscapacidadesGradoGravedad" fetch="select">
            <column name="discapacidades_grado_gravedad" not-null="true" />
        </many-to-one>
        <many-to-one name="discapacidades" class="modelo.Discapacidades" fetch="select">
            <column name="discapacidades" not-null="true" />
        </many-to-one>
        <many-to-one name="deficiencias" class="modelo.Deficiencias" fetch="select">
            <column name="deficiencias" not-null="true" />
        </many-to-one>
        <many-to-one name="minusvalias" class="modelo.Minusvalias" fetch="select">
            <column name="minusvalias" not-null="true" />
        </many-to-one>
        <many-to-one name="afiliadoDiscapacitado" class="modelo.AfiliadoDiscapacitado">
            <column name="afiliado_discapacitado_id" not-null="true" />
        </many-to-one>
    </class>
</hibernate-mapping>


I would really appreciate a hand..


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.