• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

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

 
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

 
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • 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
 
Never trust an airline that limits their passengers to one carry on iguana. Put this tiny ad in your shoe:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic