Hi, I have
Code:
public class A{
private int idA;
private String nameA;
private List <B> bs
}
public class B{
private int idB;
private String nameB;
}
Now in my database i have;
**********
Table A
idA (PK)
nameA
**********
**********
TAble B
idB (PK)
idA (FK)
nameB
**********
Now i already have in table A (5,"row1A") and in B i have (1,5,"row1B")
i want to add in B one more row so i'll have (1,5,"row1B") (2,5,"row1B")
so i can't figure out what to do in my method
Code:
try {
session = hibernateFactory.openSession();
tx = session.beginTransaction();
?
?
?
tx.commit();
session.flush ();
}
catch (RuntimeException e){
tx.rollback ();
e.printStackTrace ();
}
finally {
session.close ();
}
My hbm.xml are:
Code:
<hibernate-mapping package="seguridad.entidad">
<class name="Sistema" table="sistema" lazy="false" >
<id name="cod_sistema" type="java.lang.Integer" >
<column name="cod_sistema" not-null="true"/>
<generator class="increment"/>
</id>
<property
name="nom_sistema"
type="java.lang.String"
update="true"
insert="true"
column="nom_sistema"
/>
<property
name="ind_bloqueo"
type="java.lang.Boolean"
update="true"
insert="true"
column="ind_bloqueo"
/>
<property
name="url_index"
type="java.lang.String"
update="true"
insert="true"
column="url_index"
/>
<bag name="modulos" cascade="all">
<key column="cod_sistema"/>
<one-to-many class="Modulo"/>
</bag>
</class>
</hibernate-mapping>
<hibernate-mapping package="seguridad.entidad">
<class name="Modulo" table="modulo" lazy="false" >
<id name="cod_modulo" type="java.lang.Integer" >
<column name="cod_modulo" not-null="true"/>
<generator class="increment"/>
</id>
<property
name="nom_modulo"
type="java.lang.String"
update="true"
insert="true"
column="nom_modulo"
/>
<property
name="ind_bloqueo"
type="java.lang.Boolean"
update="true"
insert="true"
column="ind_bloqueo"
/>
<bag name="paginas" cascade="all">
<key column="cod_modulo"/>
<one-to-many class="Pagina"/>
</bag>
</class>
</hibernate-mapping>