-->
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: mixing EntityMode.POJO and EntityMode.MAP
PostPosted: Wed Jan 21, 2009 9:27 am 
Newbie

Joined: Tue Jan 13, 2009 11:49 am
Posts: 11
Hi,

I have some Entities that are mapped to POJOs. And to each of them I have an Entity that I save with a session of type EntityMode.MAP that have a persistent relation to the corresponding POJO-mapped entity.

Example:

I have a class Person that is persisted via hibernate.
Sometimes I want to create something I call PersonDetail which is persisted by creating a map with its attributes and then persisted in its own database table with a session in EntityMode.MAP.

Problem:

Now, the PersonDetail has a many-to-one relationship to Person. When I create the PersonDetail, I have the associated Person loaded into my Person POJO. Now I need to put this relationship into my map

Person person = ...;
Map<String,Object> versionMap = new HashMap<String,Object>();
versionMap.put("info","test");
versionMap.put("person",pojoToMap(person));
session.save(versionMap);

Question:

What must the "pojoToMap" method do? It can't just return the pojo since I need a map for EntityMode.MAP. But is it sufficient to return a map that only contains "$type$" and "id"? And if I call this method twice for the same person, must I return the same map or just one with identical values?

thanks in advance for any help.

Dirk


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.