数据库有A、B两张表,A表中的主键为联合主键,其中一个主键是B的外键,用annotation怎么注解呢?
用XML配置可以用key-many-to-one,但是换成annotation没搞明白怎么配。。@Entity@Table(name="TCHAREG_RULES")pu...
用XML配置可以用key-many-to-one,但是换成annotation没搞明白怎么配。。
@Entity
@Table(name="TCHAREG_RULES")
public class A implements java.io.Serializable {
private AId id;
private String name;
public String getName() {
return this.name;
}
@Id
public AId getId() {
return this.id;
}
public void setName(String name) {
this.name = name;
}
public void setId(AId id) {
this.id = id;
}
}
@Embeddable
public class AId implements Serializable {
private String Id;
private B b;
public String getId() {
return this.Id;
}
public Tcharge getB() {
return this.b;
}
public void setFuncId(String funcId) {
this.funcId = funcId;
}
public void setTcharge(Tcharge tcharge) {
this.tcharge = tcharge;
}
}
最后几个方法没改过来。。
public B getB(){
return this.b;
} 展开
@Entity
@Table(name="TCHAREG_RULES")
public class A implements java.io.Serializable {
private AId id;
private String name;
public String getName() {
return this.name;
}
@Id
public AId getId() {
return this.id;
}
public void setName(String name) {
this.name = name;
}
public void setId(AId id) {
this.id = id;
}
}
@Embeddable
public class AId implements Serializable {
private String Id;
private B b;
public String getId() {
return this.Id;
}
public Tcharge getB() {
return this.b;
}
public void setFuncId(String funcId) {
this.funcId = funcId;
}
public void setTcharge(Tcharge tcharge) {
this.tcharge = tcharge;
}
}
最后几个方法没改过来。。
public B getB(){
return this.b;
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询