Java Mailing List Archive

http://www.gg3721.com/

Home » users.openjpa »

Map<ClassA,ClassB> problem

Gerard

2008-07-17

Replies: Find Java Web Hosting

Author LoginPost Reply

I'm trying to map the followin classes:
public class Category implements java.io.Serializable {
  @Id
  @GeneratedValue
  private Long id;

  @OneToMany
  @JoinColumn(name = "CATEGORY_ID")
  @MapKey(name="language")
  private Map<Language, CategoryDescription> description = new
HashMap<Language, CategoryDescription>();
  ...
}

public class Language implements java.io.Serializable {
  @Id
  @GeneratedValue
  private Long id;
  ...
}

public class CategoryDescription implements java.io.Serializable {
  @Id
  @GeneratedValue
  private Long id;
 
  @ManyToOne(optional=false)
  private Language language;
  ...
}

This worked for me using Hibernate and generated the following tables:
CATEGORY(ID,...)
LANGUAGE(ID,...)
CATEGORYDESCRIPTION(ID,LANGUAGE_ID,CATEGORY_ID,...)

Using OpenJPA I receive the following error:
<openjpa-1.1.0-r422266:657916 fatal user error>
org.apache.openjpa.persistence.ArgumentException: Map field
"at.idsoftware.vocabulary.data.Category.description" is attempting to use a
map table, but its key is mapped by another field. Use an inverse key or
join table mapping.

How to map this?
Thanks!
--
Sent from the OpenJPA Users mailing list archive at Nabble.com.

©2008 gg3721.com - Jax Systems, LLC, U.S.A.