KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I need to map Oracle XMLType column to hibernate entity class. There is a working (and I think well-known) solution that involves implementing UserType ; however, I cannot use it because requires importing Oracle xml parsers, which in turn causes many problems . I'm ok with accessing value of xml column as a string and leave transformation to the code that manipulates entity, but I cannot find the way to read value from and write it to database. What I have tried so far: Declaring property in entity class as String . Result - value is read as null . If property is just Serializable , I get "cannot deserialize" exception. Using @Formula annotation ( CAST xmlCol as varchar2(1000) ). Result - value is not stored Using @Loader and putting CAST in SELECT . That was the most promising attempt - value was read and stored successfully, but when it comes to loading collection of entities that contain xml column, I get null (Hibernate doesn't use sql in @Loader if underlying table is LEFT JOIN ed). Another approach that I believe should work is to have xml column as String (for writing) plus dummy field for reading with @Formula ; however, it looks like a dirty hack to me, and I'd prefer not to do so unless I have no choice. Finally, the very last thing I can do is to change DB Schema (also more that 1 option, like view + triggers, column data type change), but this is not a good option for me either. I wonder if I missed something or maybe there is a way to make (3) work?
Tags (comma-separated)
Save Edits
Cancel