• 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
  • Liutauras Vilda
  • Bear Bibeault
  • Junilu Lacar
  • Martin Vashko
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Scott Selikoff
  • salvin francis
  • Piet Souris

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
 
permaculture is largely about replacing oil with people. And one tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!