-->
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.  [ 3 posts ] 
Author Message
 Post subject: return empty node for null properties with EntityMode.DOM4J
PostPosted: Mon Jul 03, 2006 11:19 am 
Beginner
Beginner

Joined: Mon Aug 01, 2005 3:51 pm
Posts: 22
Is there a way to make hibernate return an empty node for properties that have a null value?

For example

class Person {
Long id;
String firstName;
String lastName;
}

1,Bill,Salvucci
2,,Smith

Currently the xml document returned would look like:
<Person>
<id>1</id>
<firstName>Bill</firstName>
<lastName>Salvucci</lastName>
</Person>
<Person>
<id>2</id>
<lastName>Smith</lastName>
</Person>


I would like it to look like:
<Person>
<id>1</id>
<firstName>Bill</firstName>
<lastName>Salvucci</lastName>
</Person>
<Person>
<id>2</id>
<firstName/>
<lastName>Smith</lastName>
</Person>


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 14, 2006 4:08 am 
Newbie

Joined: Mon Mar 20, 2006 8:42 am
Posts: 11
hi

i dont think there is a way to make hibernate return an empty node for properties that have a null value.

but there is a work around

You can change your schema and set default value of the columns to empty string rather than null. In that case hibernate returns empty node when there is no data against a column.

_________________
Aisha


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 04, 2006 5:14 pm 
Beginner
Beginner

Joined: Mon Aug 01, 2005 3:51 pm
Posts: 22
That will only work for VARCHAR columns.

I'm suprised no else is asking for this. It makes the xsl much more complicated and less performant if the elements/attributes aren't returned for null values.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.