当前位置: 动力学知识库 > 问答 > 编程问答 >

google app engine - jpa, more then one primary key

问题描述:

I have an Article entity and an ArticleCode entity. Aritcle Code has Article as forgeing key but is has also a second and third primary key.

The example below isnt possible because Article isnt serializable. Any ideas?

Thanks,

Ralph

@Entity

public class Article {

@Id

@GeneratedValue(strategy=GenerationType.TABLE)

private Long id;

public Long getId() { return id; }

}

@Entity

@IdClass(com.google.gwt.sample.stockwatcher.server.huflattich.ArticleCode.ComposedIdKey.class)

public class ArticleCode {

@Id

@OneToOne

private Article article;

@Id

@Column(name="coding_system")

private String codingSystem;

@Id

private String code;

...

public static class ComposedIdKey implements Serializable {

public Article article;

public String codingSystem;

public String code;

public ComposedIdKey () { }

public ComposedIdKey(Article article, String codingSystem, String code) {

this.article = article;

this.codingSystem = codingSystem;

this.code = code;

}

...

}

}

网友答案:

ohh, in google's BigTable it is impossible to have more then one primary key.

分享给朋友:
您可能感兴趣的文章:
随机阅读: