Por ejemplo, teniendo una tabla card con varios campos de referencia a otra tabla skill. Y teniendo campos card1,card2 que hacen referencia a la propia tabla la clase quedaría así:
import java.io.Serializable;
import java.util.Collection;
import javax.persistence.*;
import org.openxava.annotations.*;
@Entity
@Table(name = "card", catalog = "soccer", schema = "master")
@View(members=
"Otros datos [#id,name;description;];"+
" [rarity, type, subtype;" +
"price, points, cost, dust;" +
"health, ability, level, collectible;" +
"image, frame, cardset;" +
"skill1; skill2; skill3;" +
"card1Id; card2Id;" +
"classId;" +
"];" +
"cardPackCollection")
import java.util.Collection;
import javax.persistence.*;
import org.openxava.annotations.*;
@Entity
@Table(name = "card", catalog = "soccer", schema = "master")
@View(members=
"Otros datos [#id,name;description;];"+
" [rarity, type, subtype;" +
"price, points, cost, dust;" +
"health, ability, level, collectible;" +
"image, frame, cardset;" +
"skill1; skill2; skill3;" +
"card1Id; card2Id;" +
"classId;" +
"];" +
"cardPackCollection")
public class Card implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Basic(optional = false)
@Column(name = "id")
@DisplaySize(10)
private Integer id;
@Basic(optional = false)
@Column(name = "name")
@DisplaySize(40)
private String name;
@Basic(optional = false)
@Column(name = "description")
@DisplaySize(120)
private String description;
@ManyToOne(fetch=FetchType.LAZY)
@JoinColumn(name="skill1")
@DescriptionsList(
descriptionProperties="id,name",
order="name"
)
private Skill skill1;
@ManyToOne(fetch=FetchType.LAZY)
@JoinColumn(name="skill2")
@DescriptionsList(
descriptionProperties="id,name",
order="name"
)
private Skill skill2;
@ManyToOne(fetch=FetchType.LAZY)
@JoinColumn(name="skill3")
@DescriptionsList(
descriptionProperties="id,name",
order="name"
)
private Skill skill3;
@ManyToOne(fetch=FetchType.LAZY)
@JoinColumn(name="card1_id")
@DescriptionsList(
descriptionProperties="id,name",
order="name"
)
private Card card1Id;
@ManyToOne(fetch=FetchType.LAZY)
@JoinColumn(name="card2_id")
@DescriptionsList(
descriptionProperties="id,name",
order="name"
)
private Integer card2Id;
@OneToMany(mappedBy = "cardId", fetch = FetchType.LAZY)
private Collection cardPackCollection;
public Card() {
}
public Card(Integer id) {
this.id = id;
}
public Card(Integer id, String name, String description, Card card1Id, int card2Id ) {
this.id = id;
this.name = name;
this.description= description;
this.card1Id = card1Id;
this.card2Id = card2Id;
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Basic(optional = false)
@Column(name = "id")
@DisplaySize(10)
private Integer id;
@Basic(optional = false)
@Column(name = "name")
@DisplaySize(40)
private String name;
@Basic(optional = false)
@Column(name = "description")
@DisplaySize(120)
private String description;
@ManyToOne(fetch=FetchType.LAZY)
@JoinColumn(name="skill1")
@DescriptionsList(
descriptionProperties="id,name",
order="name"
)
private Skill skill1;
@ManyToOne(fetch=FetchType.LAZY)
@JoinColumn(name="skill2")
@DescriptionsList(
descriptionProperties="id,name",
order="name"
)
private Skill skill2;
@ManyToOne(fetch=FetchType.LAZY)
@JoinColumn(name="skill3")
@DescriptionsList(
descriptionProperties="id,name",
order="name"
)
private Skill skill3;
@ManyToOne(fetch=FetchType.LAZY)
@JoinColumn(name="card1_id")
@DescriptionsList(
descriptionProperties="id,name",
order="name"
)
private Card card1Id;
@ManyToOne(fetch=FetchType.LAZY)
@JoinColumn(name="card2_id")
@DescriptionsList(
descriptionProperties="id,name",
order="name"
)
private Integer card2Id;
@OneToMany(mappedBy = "cardId", fetch = FetchType.LAZY)
private Collection
public Card() {
}
public Card(Integer id) {
this.id = id;
}
public Card(Integer id, String name, String description, Card card1Id, int card2Id ) {
this.id = id;
this.name = name;
this.description= description;
this.card1Id = card1Id;
this.card2Id = card2Id;
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public Skill getSkill1() {
return skill1;
}
public void setSkill1(Skill skill1) {
this.skill1 = skill1;
}
public Skill getSkill2() {
return skill2;
}
public void setSkill2(Skill skill2) {
this.skill2 = skill2;
}
public Skill getSkill3() {
return skill3;
}
public void setSkill3(Skill skill3) {
this.skill3 = skill3;
}
public Card getCard1Id() {
return card1Id;
}
public void setCard1Id(Card card1Id) {
this.card1Id = card1Id;
}
return skill1;
}
public void setSkill1(Skill skill1) {
this.skill1 = skill1;
}
public Skill getSkill2() {
return skill2;
}
public void setSkill2(Skill skill2) {
this.skill2 = skill2;
}
public Skill getSkill3() {
return skill3;
}
public void setSkill3(Skill skill3) {
this.skill3 = skill3;
}
public Card getCard1Id() {
return card1Id;
}
public void setCard1Id(Card card1Id) {
this.card1Id = card1Id;
}
public Integer getCard2Id() {
return card2Id;
}
public void setCard2Id(Integer card2Id) {
this.card2Id = card2Id;
}
public Collection getCardPackCollection() {
return cardPackCollection;
}
public void setCardPackCollection(Collection cardPackCollection) {
this.cardPackCollection = cardPackCollection;
}
}
return card2Id;
}
public void setCard2Id(Integer card2Id) {
this.card2Id = card2Id;
}
public Collection
return cardPackCollection;
}
public void setCardPackCollection(Collection
this.cardPackCollection = cardPackCollection;
}
}
No hay comentarios:
Publicar un comentario