• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Hibernate - ColumnTransformer- XMLType - Use of extract() to select/assign Specific Node

 
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear Programmer.

I need your help to use extract() of oracle while mapping an attribute of an entity so that i can get perticular node of an xml store in the database.

Database Table:
Record stored in the table is
Java Model Class:


Actual Result: <APPROVER_LIST><APPROVER><EMAIL>abcd@xyz.com</EMAIL><ROLE>NOBODY</ROLE></APPROVER></APPROVER_LIST>.

Expectation Result: abcd@xyz.com

I tried with the creating function to use extract(...) and get the desired node. When i call from SQL Developer function returns the desired value as expected however with mapping it's not

Your support/guidance/hint is highly appreciated.

Thanks & Regards,
Pankaj Patel

 
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Pankaj Patel wrote:Actual Result: <APPROVER_LIST><APPROVER><EMAIL>abcd@xyz.com</EMAIL><ROLE>NOBODY</ROLE></APPROVER></APPROVER_LIST>.

Expectation Result: abcd@xyz.com


Based on the code snippet you have posted, I think the actual result is what you could expect based on the read attribute of the ColumnTransformer annotation. Using this annotation you can define a custom SQL expression to read the value from and write a value to a column. And you tell Hibernate to use the to_clob function on the PRESENT_APPROVERS column. You don't use the appropriate function to extract the value from the EMAIL node.

I have no knowledge about the Oracle database, but it seems the function you are looking for is EXTRACTVALUE. So I would expect that you need to change your code like this to get the expected result

Hope it helps!
Kind regards,
Roel
 
What a show! What atmosphere! What fun! What a tiny ad!
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic