-->
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: EntityMode.DOM4J problem with composite Id
PostPosted: Fri Jun 29, 2007 8:24 pm 
Newbie

Joined: Fri Jun 29, 2007 8:16 pm
Posts: 1
I have a persistent object

[code]@Entity
@Table(name="RTSP_URL")
@IdClass(KeyUrlRtsp.class)
public class UrlRtsp implements Serializable {

@Id
@Column(name="DEVICE_ID")
private Integer deviceId;

@Id
@Column(name="QUALITY_NAME")
private String quality;
...
}[/code]

I serialized the an database Object out an XML file using the EntityMode.DOM4J, then tried to deserialize and insert the the dom4j element to the database. The composite key is not properly deserialized.

The following is written to the XML file (correct deviceId and quality are saved):

[code]<id><deviceId>50</deviceId><quality>HIGH</quality></id>[/code]
When I use
[code] public Serializable saveDom4jElement(Element element) {
Session session = HibernateUtil.getSession();
session.setFlushMode(FlushMode.COMMIT);
Transaction transaction = session.beginTransaction();
Session dom4jSession = session.getSession(EntityMode.DOM4J);
System.out.println(element.getName());
Serializable id = dom4jSession.save(element);
transaction.commit();
return id;
}[/code]

to save the element, I have the following (both deviceId and quality are dropped and set to null):

[code]DEBUG - Pre-invalidating space [VW_CONTENT_URL_RTSP]
DEBUG - Inserting entity: [xxxxxxxxxxxxxxxxxxx.UrlRtsp#component[deviceId,quality]{deviceId=null, quality=null}]
DEBUG - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
DEBUG - insert into VW_CONTENT_URL_RTSP (DEVICE_NAME, PREFIX, SUFFIX, THRESHOLD, DEVICE_ID, QUALITY_NAME) values (?, ?, ?, ?, ?, ?)
DEBUG - preparing statement
DEBUG - Dehydrating entity: [xxxxxxxxxxxxxxxxxxx.UrlRtsp#component[deviceId,quality]{deviceId=null, quality=null}][/code]

I have a similar persistent object with the composite-id defined in hmb.xml as
[code] <composite-id name="id" class="xxxxxx.KeyContentUrls">
<key-property name="inventoryId" column="inventory_id"/>
<key-property name="deviceName" column="device_name"/>
<key-property name="qualityName" column="quality_name"/>
</composite-id>[/code]and KeyContentUrls is serialized and deserialized properly, the correct value for inventory_id, device_name, quality_name are inserted correctly. I wonder if this is a problem with annotation. Has anyone seen similiar problem?


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.