-->
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: JPA 2.0, Embeddable with Map used multiple times in Entity
PostPosted: Thu Dec 10, 2009 7:17 am 
Newbie

Joined: Thu Dec 10, 2009 6:32 am
Posts: 1
Let's consider the following code

@Embeddable
public class MultiLanguageString {
private String defaultValue;

@ElementCollection
private Map<String, String> otherValues;

// getters, setter, ...
}

which models a String that can beside a defaultValue have values in other languages (i.e. key of the map is something like "en" or "de").

Then I want to use this multiple times in an entity.

@Entity
public class MultiLangDataSet {
@Embedded
@AttributeOverride(name="defaultValue", column=@Column(name="DEFAULTNAME"))
@AssociationOverride(name="otherValues", joinTable=@JoinTable(name="OVALUESNAME")
private MultiLanguageString name;

@Embedded
@AttributeOverride(name="defaultValue", column=@Column(name="SDESCRIPTION"))
@AssociationOverride(name="otherValues", joinTable=@JoinTable(name="OVALUESDESC")
private MultiLanguageString shortDescription;

// getters, setters, ...
}

Multiple usage of MultiLanguageString within an entity doesn't seem to be possible with JPA 2 because while I can disambiguate the "defaultValue" field with AttributeOverride it's not possible to do the same with the map field otherValues (AssociationOverride doesn't seem to work with ElementCollection, when I try to change the collection table name with it). But the example works, when I have only one MultiLanguageString object in MultiLangDataSet.

Is this a design flaw or a bug of JPA 2 or am I missing something? Does Hibernate itself provides a mapping extension that handles this usage szenario?

Clemens


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.