-->
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.  [ 4 posts ] 
Author Message
 Post subject: XML-Relational mapping
PostPosted: Mon Aug 28, 2006 11:54 am 
Newbie

Joined: Mon Aug 28, 2006 11:37 am
Posts: 3
Hi there,

I was wondering if someone was able to help me out with the following.
I have created a Hibernate mapping file that maps POJOs to both a database and an XML file.

Lets say xml looks like this:
<message>
<person>
<name>Blabla</name>
</person>
<text>djfh lksdjhlsdkjhasdf</text>
</message>

My db like this:
table: Messages
columns: id, person, message

My pojo like this:
public class Message implements java.io.Serializable {
private Long id;
private String name;
private String message;

...constructor, getter and setters....

And my mapping file as follows:
<hibernate-mapping>
<class name="nl.abz.fish.hibernate.Message" table="MESSAGES" node="MESSAGE">
<id name="id" type="java.lang.Long">
<column name="ID" length="10" />
<generator class="identity" />
</id>
<property name="name" type="java.lang.String">
<column name="NAME" length="10" node="name"/>
</property>
<property name="message" type="java.lang.String">
<column name="message" length="10" node="text" />
</property>

Now when I try to persist the xml it does not save the message text, so it seems that it cannot access this nested value.

Is there anyway I can map properties of a POJO to a nested Element??

Any suggestion would be greatly appreciated.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 28, 2006 11:57 am 
Newbie

Joined: Mon Aug 28, 2006 11:37 am
Posts: 3
Sorry, I meant it does not save the persons name!
It can access the message text.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 29, 2006 3:32 am 
Newbie

Joined: Mon Aug 28, 2006 11:37 am
Posts: 3
Anyone?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 04, 2006 9:40 am 
Newbie

Joined: Mon Sep 04, 2006 9:03 am
Posts: 9
Why do you need a <name> nested in <person>? Can you use <person-name> instead?

If not you can define a Person Component. Create a class Person with a property called name and map this class as component to Message. Please read: http://www.hibernate.org/hib_docs/v3/re ... -component


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

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.