问题描述:

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.

相关阅读:
Top