-->
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: nested java maps
PostPosted: Fri Jun 05, 2009 5:38 am 
Newbie

Joined: Fri Jun 05, 2009 5:05 am
Posts: 1
Hello,

I have a class with a map of maps that I want to persist.

public class Foo {
...
Map<PropertyType,Map<Date,String>> properties;
}

(A foo-object has some properties, which are unknown in advance and the history of the value of that property needs to be known/stored)

The idea is to store all properties in one table
Table PROPERTIES
Id <PK>
fooId <FK>
propertyId
Date
Value

To be able to define the hibernate-mapping I introduced a PropertyDTO which represents a row in the table.

Finally i introduced a getter/setter in Foo
public Set<PropertyDTO> getProperties() which creates a list based on the properties-map. (There is no Set instance-field)
(The setters fills the properties-map)

The problem is that when I persist a foo-object every propertyDTO is put TWICE in the table. When I create Set instance-field (and by consequence duplicate the properties in every foo-object), persisting the object works fine...

Can I avoid the duplicate insertion?


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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.