[hibernate-dev] embed-xml=false leaves you stuck
Steve Ebersole
steve at hibernate.org
Wed Dec 12 09:40:25 EST 2007
On Dec 11, 2007, at 8:02 PM, Bill Burke wrote:
> I was looking at the XML mapping support for Hibernate recently and
> have some questions/suggestions.
>
> One thing that seriously annoyed me was that if you do not have
> embed-xml="true" you can never get access to an association/
> relationship in XML format. This means that I cannot have embed-
> xml="false" and load the relationship with a fetch join. Is there
> any particular reason I'm missing here on why it was implemented in
> this fashion?
Consistency. Partially it has to do with avoiding circular references
as you mention below, but that is really a choice for the person doing
the mapping (hence why embed-xml is even an *option*). The bigger
issue here imo is the fact that the nature of XML suggests that we are
discussing structured data; structure which is generally described by
a schema or DTD. What you do not like is the "static" nature of the
choice...
I am not "an XML person". However, I believe there is an approach
which would be great and which XML supports, but I am not certain. I
am talking about representing the association as a
"link" (potentially) to another part of the document describing the
associated data on the basis that it may be shared:
<person id="1">
<name>Bill Burke</name>
<!- here, an 'employer' element would "link" to the <company
id="1"/> reference below -->
</person>
<company id="1">
...
</company>
Then, if the association data is uninitialized you would still have
the "link", but the entity data would not be included in the document.
I think that would be a great feature/option and would gladly accept
patches for that.
More information about the hibernate-dev
mailing list