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: problem in an association many-to-on/one-to-many
PostPosted: Thu Jul 06, 2006 10:25 am 
Newbie

Joined: Fri Apr 28, 2006 12:07 pm
Posts: 14
Hi everybody! I have a problem when I try to associate two tables in of a database. These are my two files of mapping:

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="configuracion.PhDevice" table="PHDEVICES">
<id name="idd" column="DEVICE_ID"/>
<property name="idt"/>
<property name="maker"/>
<property name="model"/>
<set name="c" table="CLIENTS_PHDEVICE">
<key column="DEVICE_ID"/>
<many-to-many column="CLIENT_ID" class="configuracion.Client"/>
</set>
<many-to-one name="dt" column="ID_type" lass="configuracion.DevType"/> <!--ID_type-->
</class>
</hibernate-mapping>

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="configuracion.DevType" table="DEVTYPES">
<id name="ID_type" column="DEVTYPE_ID"/>
<property name="type"/>
<property name="caracteristics"/>
<set name = "pd" inverse="true">
<key column = "ID_type" />
<one-to-many class="configuracion.PhDevice"/>
</set>
</class>
</hibernate-mapping>

and the method I use is this:

public void addDevType2PhDevice (String idtA , String idtB){
this.createAndStoreDevType("idt 1", "movil" , "IMEI_versionflex..");
this.createAndStorePhDevice("idd 1", "idt 1", "Motorola", "V3x");
Session session = HibernateUtil.getSessionFactory().getCurrentSession();
session.beginTransaction();
DevType dt = (DevType) session.load(DevType.class, idtA);
PhDevice pd = (PhDevice) session.load(PhDevice.class, "idt 1");

dt.getPd().add(pd);
session.getTransaction().commit();
}

When I run the program I there aren't any error, but the tables are like this:

DEVICE_ID IDT MAKER MODEL ID_TYPE
idd 1 idt 1 Motorola V3x (null)

DEVTYPE_ID TYPE CARACTERISTICS
idt 1 movil IMEI_versionflex...

Why is null in the ID_TYPE column???

thank you very much for your time


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.