You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@xmlbeans.apache.org by Eric Vasilik <er...@bea.com> on 2004/02/20 23:30:27 UTC
Hibernate/XmlBeans integration
I'm trying to understand some of the issues related to a
Hibernate/XmlBeans integration. As far as I can tell, the assumed goal
of such an integration is to persist/create XmlBeans via the generated
classes/interfaces. With respect to the architecture of XmlBeans v1
(XmlObject based generated interfaces), this integration approach sounds
counterintuitive.
In XmlBeans v2, we are creating an alternative to the full-fidelity
binding model. In this model, xml is marshaled/un-marshaled to/from XML
and Java objects. Full-fidelity is effectively sacrificed for
performance. In this model, I can more clearly see an integration path
to Hibernate because there is no full-fidelity backing store for the
Java objects.
Let me describe, a bit, aspects of the XmlBeans v1 full-fidelity binding
architecture (I call it Classic XmlBeans binding) which are relevant to
a Hibernate integration.
The data that an XmlObject (or any XmlBean derived from XmlObject)
reflects is not really stored in that XmlObject. It is stored as
full-fidelity (think DOM) XML store. This XML store generally stores
the XML for many XmlObjects. For example, you may have the XML:
<Customer>
<Address> ... </Address>
<Profile> ... </Profile>
</Customer>
and you may have XmlObjects (generated from the appropriate schema) for
the Customer, his Address and Profile. In this sense, an XmlObject is a
reference to a position in the XML store along with the type of that
part of the XML. The XmlBeans have methods for traversing the typed
structure of the XML. Note that there are no methods for traversing to
a parent.
A more natural way to persist an XmlObject is to persist the XML in the
backing store, along with the position of the XML (think XPointer) and
the SchemaType of that XmlObject. Persisting the individual XmlObjects
seems much less performant, in addition to loosing the full-fidelity of
the XML backing the XmlObjects.
Comments?
- Eric
-----Original Message-----
From: Brian Koehmstedt [mailto:bpk@now2000.com]
Sent: Friday, February 20, 2004 1:42 PM
To: xmlbeans-user@xml.apache.org
Subject: Re: Plans for V2?
Brian K Bonner wrote:
> Eric, David, etc.
>
> I saw someone else asked a similar question. I'm interested in
hooking
> XMLBeans up to Hibernate. It doesn't appear that there is a way to
create
> beans from a default constructor. From playing with V1, it looks like
a
> DOM implementation is created by the factory (which acts as the
"store"
> for the Java Interfaces and XML Beans handles manipulating the store
> through the setters/getters. I have looked at V2, but it appears that
the
> bean construction is the same.
>
> Hibernate requires default constructors to be available to create the
> objects from the database.
>
Well, actually, this is the lesser of Hibernate<->XMLBeans integration
problems, because you can use a net.sf.hibernate.Interceptor (see
http://www.hibernate.org/hib_docs/reference/html/manipulating-data.html#
manipulating-data-s15)
to dictate how Hibernate constructs new objects.
What's more hairy is trying to extend the XMLBeans so that Hibernate has
the getter/setter methods it needs to map to primitive database types.
I have found no way of dealing with this other than just piping the
XMLBeans generated source through a perl script that modifies the actual
code, then recompile the source.
Also I've had problems with XMLBeans creating objects for nillable XML
elements and Hibernate thinks it's something it needs to store in the
database. I've had to wrap getter methods so that it checks for 0
length strings (.getStringValue()).
Everything I've done has been pretty kludgy, frankly.
- ---------------------------------------------------------------------
To unsubscribe, e-mail: xmlbeans-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xmlbeans-user-help@xml.apache.org
Apache XMLBeans Project -- URL: http://xml.apache.org/xmlbeans/
- ---------------------------------------------------------------------
To unsubscribe, e-mail: xmlbeans-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xmlbeans-user-help@xml.apache.org
Apache XMLBeans Project -- URL: http://xml.apache.org/xmlbeans/
Re: Hibernate/XmlBeans integration
Posted by Brian Koehmstedt <ko...@acm.org>.
Eric Vasilik wrote:
> I'm trying to understand some of the issues related to a
> Hibernate/XmlBeans integration. As far as I can tell, the assumed goal
> of such an integration is to persist/create XmlBeans via the generated
> classes/interfaces. With respect to the architecture of XmlBeans v1
> (XmlObject based generated interfaces), this integration approach sounds
> counterintuitive.
Well, yes, if by counterintuitive you mean not supported by v1. That's
why I admit what I'm doing is kludgy.
> A more natural way to persist an XmlObject is to persist the XML in the
> backing store, along with the position of the XML (think XPointer) and
> the SchemaType of that XmlObject. Persisting the individual XmlObjects
> seems much less performant, in addition to loosing the full-fidelity of
> the XML backing the XmlObjects.
>
> Comments?
When you say persist the XML in the backing store, how would that be
done? Store raw XML in the database?
My purposes aren't really to persist the XML (otherwise I'd use an XML
database like Xindice). What I really want to do is essentially convert
an XMLSchema to a SQL/relational schema so that I can build an
application that takes advantage of a relational data store, but at the
same time can occasionally import/export data in the XML format. The
relational schema should represent objects intuitively, so that other
applications in the enterprise (that aren't using XMLBeans) can make
sense of the relational schema.
As far as efficiency, I don't need to create XML "on the fly" when I
retrieve objects from the database. Most of the time I don't need the
XML at all. It's just when I want to export the data that I want it in
an XML format. Since this is an occasional operation, the export can be
expensive. However, I'd like the Hibernate operations
(retrieve/save/etc) to be efficient.
- ---------------------------------------------------------------------
To unsubscribe, e-mail: xmlbeans-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xmlbeans-user-help@xml.apache.org
Apache XMLBeans Project -- URL: http://xml.apache.org/xmlbeans/
Re: Hibernate/XmlBeans integration
Posted by Brian Koehmstedt <ko...@acm.org>.
Eric Vasilik wrote:
> I'm trying to understand some of the issues related to a
> Hibernate/XmlBeans integration. As far as I can tell, the assumed goal
> of such an integration is to persist/create XmlBeans via the generated
> classes/interfaces. With respect to the architecture of XmlBeans v1
> (XmlObject based generated interfaces), this integration approach sounds
> counterintuitive.
Well, yes, if by counterintuitive you mean not supported by v1. That's
why I admit what I'm doing is kludgy.
> A more natural way to persist an XmlObject is to persist the XML in the
> backing store, along with the position of the XML (think XPointer) and
> the SchemaType of that XmlObject. Persisting the individual XmlObjects
> seems much less performant, in addition to loosing the full-fidelity of
> the XML backing the XmlObjects.
>
> Comments?
When you say persist the XML in the backing store, how would that be
done? Store raw XML in the database?
My purposes aren't really to persist the XML (otherwise I'd use an XML
database like Xindice). What I really want to do is essentially convert
an XMLSchema to a SQL/relational schema so that I can build an
application that takes advantage of a relational data store, but at the
same time can occasionally import/export data in the XML format. The
relational schema should represent objects intuitively, so that other
applications in the enterprise (that aren't using XMLBeans) can make
sense of the relational schema.
As far as efficiency, I don't need to create XML "on the fly" when I
retrieve objects from the database. Most of the time I don't need the
XML at all. It's just when I want to export the data that I want it in
an XML format. Since this is an occasional operation, the export can be
expensive. However, I'd like the Hibernate operations
(retrieve/save/etc) to be efficient.
- ---------------------------------------------------------------------
To unsubscribe, e-mail: xmlbeans-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xmlbeans-user-help@xml.apache.org
Apache XMLBeans Project -- URL: http://xml.apache.org/xmlbeans/
Re: Hibernate/XmlBeans integration
Posted by Brian K Bonner <br...@paraware.com>.
Eric, please see my comments below:
"Eric Vasilik" <er...@bea.com> wrote on 02/20/2004 05:30:27 PM:
> I'm trying to understand some of the issues related to a
> Hibernate/XmlBeans integration. As far as I can tell, the assumed goal
> of such an integration is to persist/create XmlBeans via the generated
> classes/interfaces. With respect to the architecture of XmlBeans v1
> (XmlObject based generated interfaces), this integration approach sounds
> counterintuitive.
I'm not sure I would say it's counterintuitive. I would probably say that
it
has a set of hurdles.
The reason we are interested in pursuing this is:
1. Relational databases are fairly well-entrenched in businesses and
reasonably mature.
2. Mainstream Tools are available that allow users to access the
collections of the data in the relational databases.
3. We are looking for an efficient mechanism to handle XML <-> Java
Object <-> Relational. Hibernate efficiently handles the latter
portion of this mechanism.
XMLBeans was of interest based upon how I'll describe it as marrying Java
Interfaces to an XML Schema.
The full-fidelity of the Infoset aspect of XMLBeans V1 is probably not as
important in our particular need.
>
> In XmlBeans v2, we are creating an alternative to the full-fidelity
> binding model. In this model, xml is marshaled/un-marshaled to/from XML
> and Java objects. Full-fidelity is effectively sacrificed for
> performance. In this model, I can more clearly see an integration path
> to Hibernate because there is no full-fidelity backing store for the
> Java objects.
>
> Let me describe, a bit, aspects of the XmlBeans v1 full-fidelity binding
> architecture (I call it Classic XmlBeans binding) which are relevant to
> a Hibernate integration.
>
> The data that an XmlObject (or any XmlBean derived from XmlObject)
> reflects is not really stored in that XmlObject. It is stored as
> full-fidelity (think DOM) XML store. This XML store generally stores
> the XML for many XmlObjects. For example, you may have the XML:
>
> <Customer>
> <Address> ... </Address>
> <Profile> ... </Profile>
> </Customer>
>
> and you may have XmlObjects (generated from the appropriate schema) for
> the Customer, his Address and Profile. In this sense, an XmlObject is a
> reference to a position in the XML store along with the type of that
> part of the XML. The XmlBeans have methods for traversing the typed
> structure of the XML. Note that there are no methods for traversing to
> a parent.
>
> A more natural way to persist an XmlObject is to persist the XML in the
> backing store, along with the position of the XML (think XPointer) and
> the SchemaType of that XmlObject. Persisting the individual XmlObjects
> seems much less performant, in addition to loosing the full-fidelity of
> the XML backing the XmlObjects.
Agreed, since this is the storage mechanism that the Classic XmlBeans
binding uses, I can see why you suggest this, but, this was not what we
were after.
Organizations that we have come in contact with have a strong affinity
toward where they want there data stored and "how" they want it stored,
down to the attribute name of an Entity. Hibernate does a good job of
allowing a set of code to work with a variety of relational databases.
>
> Comments?
>
> - Eric
>
>
>
>
> -----Original Message-----
> From: Brian Koehmstedt [mailto:bpk@now2000.com]
> Sent: Friday, February 20, 2004 1:42 PM
> To: xmlbeans-user@xml.apache.org
> Subject: Re: Plans for V2?
>
> Brian K Bonner wrote:
> > Eric, David, etc.
> >
> > I saw someone else asked a similar question. I'm interested in
> hooking
> > XMLBeans up to Hibernate. It doesn't appear that there is a way to
> create
> > beans from a default constructor. From playing with V1, it looks like
> a
> > DOM implementation is created by the factory (which acts as the
> "store"
> > for the Java Interfaces and XML Beans handles manipulating the store
> > through the setters/getters. I have looked at V2, but it appears that
> the
> > bean construction is the same.
> >
> > Hibernate requires default constructors to be available to create the
> > objects from the database.
> >
>
> Well, actually, this is the lesser of Hibernate<->XMLBeans integration
> problems, because you can use a net.sf.hibernate.Interceptor (see
> http://www.hibernate.org/hib_docs/reference/html/manipulating-data.html#
> manipulating-data-s15)
>
> to dictate how Hibernate constructs new objects.
>
> What's more hairy is trying to extend the XMLBeans so that Hibernate has
> the getter/setter methods it needs to map to primitive database types.
> I have found no way of dealing with this other than just piping the
> XMLBeans generated source through a perl script that modifies the actual
> code, then recompile the source.
>
> Also I've had problems with XMLBeans creating objects for nillable XML
> elements and Hibernate thinks it's something it needs to store in the
> database. I've had to wrap getter methods so that it checks for 0
> length strings (.getStringValue()).
>
> Everything I've done has been pretty kludgy, frankly.
>
>
>
>
>
> - ---------------------------------------------------------------------
> To unsubscribe, e-mail: xmlbeans-user-unsubscribe@xml.apache.org
> For additional commands, e-mail: xmlbeans-user-help@xml.apache.org
> Apache XMLBeans Project -- URL: http://xml.apache.org/xmlbeans/
>
>
> - ---------------------------------------------------------------------
> To unsubscribe, e-mail: xmlbeans-user-unsubscribe@xml.apache.org
> For additional commands, e-mail: xmlbeans-user-help@xml.apache.org
> Apache XMLBeans Project -- URL: http://xml.apache.org/xmlbeans/
>
- Brian
- ---------------------------------------------------------------------
To unsubscribe, e-mail: xmlbeans-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xmlbeans-user-help@xml.apache.org
Apache XMLBeans Project -- URL: http://xml.apache.org/xmlbeans/
Re: Hibernate/XmlBeans integration
Posted by Brian K Bonner <br...@paraware.com>.
Eric, please see my comments below:
"Eric Vasilik" <er...@bea.com> wrote on 02/20/2004 05:30:27 PM:
> I'm trying to understand some of the issues related to a
> Hibernate/XmlBeans integration. As far as I can tell, the assumed goal
> of such an integration is to persist/create XmlBeans via the generated
> classes/interfaces. With respect to the architecture of XmlBeans v1
> (XmlObject based generated interfaces), this integration approach sounds
> counterintuitive.
I'm not sure I would say it's counterintuitive. I would probably say that
it
has a set of hurdles.
The reason we are interested in pursuing this is:
1. Relational databases are fairly well-entrenched in businesses and
reasonably mature.
2. Mainstream Tools are available that allow users to access the
collections of the data in the relational databases.
3. We are looking for an efficient mechanism to handle XML <-> Java
Object <-> Relational. Hibernate efficiently handles the latter
portion of this mechanism.
XMLBeans was of interest based upon how I'll describe it as marrying Java
Interfaces to an XML Schema.
The full-fidelity of the Infoset aspect of XMLBeans V1 is probably not as
important in our particular need.
>
> In XmlBeans v2, we are creating an alternative to the full-fidelity
> binding model. In this model, xml is marshaled/un-marshaled to/from XML
> and Java objects. Full-fidelity is effectively sacrificed for
> performance. In this model, I can more clearly see an integration path
> to Hibernate because there is no full-fidelity backing store for the
> Java objects.
>
> Let me describe, a bit, aspects of the XmlBeans v1 full-fidelity binding
> architecture (I call it Classic XmlBeans binding) which are relevant to
> a Hibernate integration.
>
> The data that an XmlObject (or any XmlBean derived from XmlObject)
> reflects is not really stored in that XmlObject. It is stored as
> full-fidelity (think DOM) XML store. This XML store generally stores
> the XML for many XmlObjects. For example, you may have the XML:
>
> <Customer>
> <Address> ... </Address>
> <Profile> ... </Profile>
> </Customer>
>
> and you may have XmlObjects (generated from the appropriate schema) for
> the Customer, his Address and Profile. In this sense, an XmlObject is a
> reference to a position in the XML store along with the type of that
> part of the XML. The XmlBeans have methods for traversing the typed
> structure of the XML. Note that there are no methods for traversing to
> a parent.
>
> A more natural way to persist an XmlObject is to persist the XML in the
> backing store, along with the position of the XML (think XPointer) and
> the SchemaType of that XmlObject. Persisting the individual XmlObjects
> seems much less performant, in addition to loosing the full-fidelity of
> the XML backing the XmlObjects.
Agreed, since this is the storage mechanism that the Classic XmlBeans
binding uses, I can see why you suggest this, but, this was not what we
were after.
Organizations that we have come in contact with have a strong affinity
toward where they want there data stored and "how" they want it stored,
down to the attribute name of an Entity. Hibernate does a good job of
allowing a set of code to work with a variety of relational databases.
>
> Comments?
>
> - Eric
>
>
>
>
> -----Original Message-----
> From: Brian Koehmstedt [mailto:bpk@now2000.com]
> Sent: Friday, February 20, 2004 1:42 PM
> To: xmlbeans-user@xml.apache.org
> Subject: Re: Plans for V2?
>
> Brian K Bonner wrote:
> > Eric, David, etc.
> >
> > I saw someone else asked a similar question. I'm interested in
> hooking
> > XMLBeans up to Hibernate. It doesn't appear that there is a way to
> create
> > beans from a default constructor. From playing with V1, it looks like
> a
> > DOM implementation is created by the factory (which acts as the
> "store"
> > for the Java Interfaces and XML Beans handles manipulating the store
> > through the setters/getters. I have looked at V2, but it appears that
> the
> > bean construction is the same.
> >
> > Hibernate requires default constructors to be available to create the
> > objects from the database.
> >
>
> Well, actually, this is the lesser of Hibernate<->XMLBeans integration
> problems, because you can use a net.sf.hibernate.Interceptor (see
> http://www.hibernate.org/hib_docs/reference/html/manipulating-data.html#
> manipulating-data-s15)
>
> to dictate how Hibernate constructs new objects.
>
> What's more hairy is trying to extend the XMLBeans so that Hibernate has
> the getter/setter methods it needs to map to primitive database types.
> I have found no way of dealing with this other than just piping the
> XMLBeans generated source through a perl script that modifies the actual
> code, then recompile the source.
>
> Also I've had problems with XMLBeans creating objects for nillable XML
> elements and Hibernate thinks it's something it needs to store in the
> database. I've had to wrap getter methods so that it checks for 0
> length strings (.getStringValue()).
>
> Everything I've done has been pretty kludgy, frankly.
>
>
>
>
>
> - ---------------------------------------------------------------------
> To unsubscribe, e-mail: xmlbeans-user-unsubscribe@xml.apache.org
> For additional commands, e-mail: xmlbeans-user-help@xml.apache.org
> Apache XMLBeans Project -- URL: http://xml.apache.org/xmlbeans/
>
>
> - ---------------------------------------------------------------------
> To unsubscribe, e-mail: xmlbeans-user-unsubscribe@xml.apache.org
> For additional commands, e-mail: xmlbeans-user-help@xml.apache.org
> Apache XMLBeans Project -- URL: http://xml.apache.org/xmlbeans/
>
- Brian
- ---------------------------------------------------------------------
To unsubscribe, e-mail: xmlbeans-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xmlbeans-user-help@xml.apache.org
Apache XMLBeans Project -- URL: http://xml.apache.org/xmlbeans/