casolorz
casolorz

Reputation: 9574

CriteriaBuilder where clause with XMLType

I have a database column with XML. I am using JPA (eclipselink) to access it. The database is oracle so I am using oracle.xdb.XMLType and a @Customizer annotation. It all works great.

Now I need to use the CriteriaBuilder to create a query using the XML column in the where clause.

Basically I need to recreate this with CriteriaBuilder (I do have CriteriaBuilder working for non XML columns):

SELECT id, somecolumn, xmlcol FROM sometable WHERE EXTRACTVALUE(xmlcol,'//path/path')='somevalue'; 

Any idea how to do this?

Thanks.

Upvotes: 0

Views: 595

Answers (1)

James
James

Reputation: 18379

You should be able to use the JPA CriteriaBuilder function() API to call this function.

If you need to do something more advanced you could use an EclipseLink Expression query, or mix Expressions and Criteria,

http://wiki.eclipse.org/EclipseLink/UserGuide/JPA/Basic_JPA_Development/Querying/Criteria#JpaCriteriaBuilder_and_EclipseLink_Extensions

Upvotes: 1

Related Questions