-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Embedding entity references in XMLTYPE column
PostPosted: Fri Oct 26, 2007 2:40 pm 
Newbie

Joined: Mon Mar 08, 2004 12:32 pm
Posts: 7
For reasons I won't get into here, we need to pack a bunch of information into an XMLTYPE column. I've got a custom user type that converts back and forth between the XML that lives in the database and a Map in memory.

Currently, I can store values in the Map such as lists, numbers, strings.

That works like a charm, but I'd like to store entity references as well. In the XML, an entity reference would get collapsed down to something like:

Code:
<entityref entityname="person" id="342"/>


Stripping a primary key out of an entity is easy enough, but coming back from XML, I need to instantiate the entity (or a proxy) so the resulting Map contains a usable Person.

I've hacked around a bit - by subclassing AbstractType, I've got access to a SessionImplementor during loading, but I'm clearly violating some sort of contract as I keep getting exceptions (that Hibernate reports are likely caused by session abuse). This happens when I call instantiate, internalLoad or immediateLoad.

Is there a safe way to do what I'm trying to do? Or is this impossible from a UserType?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.