Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Pankaj Patel
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • 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

 
Roel De Nijs
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic