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?
|