JPA support for XML data type columns

For the new project that we are launching (which uses JPA 2 on top of Hibernate 3), we need to be able to store XML documents and then request their contents and structure later. The databases we would like to support are DB2, Oracle, and SQLServer.

I know that all three database providers support their own XML query (using SQL and XQuery statements), but is there any direct support inside Hibernate for this? In other words, can I write one set of access codes for the sleeping channel that agnostically queries all 3 types of databases using the built-in Hibernate / JPA function, or will I need a code job for each type of DB?

I appreciate that I could define a column as an @Lob column, and then read all the records, analyze and check, but I was hoping to use the capabilities of the DB engine, rather than doing it myself.

For reference, we will always use only one taste of the database, this is just what we want to be able to support all 3 if we need to.

Thanks Steve

+6
xml orm hibernate jpa
source share
1 answer

JPA does not offer specific support for these branded types outside of Lob . For more advanced support, I think you will have to implement some custom Hibernate types. The following documents may give you some ideas.

Of course, they will be database specific and make the code less portable.

In relation to the AFAIK request, any function that is called in the WHERE the HQL operator and is unknown to Hibernate, as well as in the database, is passed. This way you can use certain functions. But again, this will make the query database specific. Perhaps consider using orm.xml mappings for specific deployments.

+2
source share

All Articles