[hibernate-dev] embed-xml=false leaves you stuck

Bill Burke bburke at redhat.com
Wed Dec 12 11:15:17 EST 2007



Steve Ebersole wrote:
> 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...
> 

Schema can allow for partial documents.  The EE 5 schema is one, but 
unrelated, example.



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

I've actually been thinking of implementing this, but not in the way you 
are talking about.  Again, the problems resides with how hibernate 
currently implements DOM4J mode and I'm pretty sure that just plugging 
in a new tupleizer won't work.


What I'm thinking of is a RESTful approach to interacting with hibernate 
over the web and using hyperlinks/URIs to reference 
associations/relationships.

GET http://foo.com/customerdb/customers/434234

<customer>
    <name>Bill Burke</name>
    <address><href>http://foo.com/customerdb/address/432</href></address>
    <accounts>
       <href>http://foo.com/customerdb/customer/434234/accounts</href>
    </accounts>
</customer>

If you wanted more data then just do:

http://foo.com/customerdb/customers/434234?fetch=accounts&fetch=address

Then for updates send partial documents to server for updating

PUT http://foo.com/customerdb/customers/434234

<customer>
    <name>William Burke</name>
</customer>

XML Schema could be used to control how partial a document could be.


Another EntityMode I want to write is a Restful JSON one.  I actually 
think this might be doable solely by writing a tuplelizer for the 
dynamic map mode, so I might prototype this first rather than fuck 
around with hibernate at all...

-- 
Bill Burke
JBoss, a division of Red Hat
http://bill.burkecentral.com



More information about the hibernate-dev mailing list