-->
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: best practices for @MapKey
PostPosted: Wed Jan 07, 2009 5:23 am 
Newbie

Joined: Wed Apr 23, 2008 11:11 pm
Posts: 19
Hi there,

I am using the @MapKey annotation to create a map of "properties" for an object and I wanted to have feedback on any best practices. Searching the web and hibernates books yield not result.

What I have basically is an ITEM table with a one to many relationship on a PROPERTY table. The property defines basically a name (String) and a value (could be of multiple type). I use the flat table mapping for this.

In my entity I have something like this

Code:
@OneToMany(
     mappedBy = "item",
     fetch = FetchType.LAZY,
     targetEntity = ItemPropertyEntity.class)
@MapKey(name = "propertyName")
@Cascade({org.hibernate.annotations.CascadeType.DELETE_ORPHAN})
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
private Map<String, ItemPropertyEntity> properties = new HashMap<String, ItemPropertyEntity>();


I want to expose a meaningful API in the ItemEntity class to add/update and remove ItemProperty instances. Any best practice to do this?

Thanks,
Stéphane


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.