langhua9527 2008-11-10 09:24 采纳率: 0%
浏览 219
已采纳

hibernate配置List的问题

[code="java"]
//产品分类
public class AykjProducterSort implements Serializable{
private int id;
private String sortname; //产品分类名
private AykjProducterSort aykjParentPid; //父分类
private Set aykjChildrenId; //子分类
private List< :wink: AykjProperties> producterSortProperties;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getSortname() {
return sortname;
}
public void setSortname(String sortname) {
this.sortname = sortname;
}
public List getProducterSortProperties() {
return producterSortProperties;
}
public void setProducterSortProperties(List producterSortProperties) {
this.producterSortProperties = producterSortProperties;
}
public AykjProducterSort getAykjParentPid() {
return aykjParentPid;
}
public void setAykjParentPid(AykjProducterSort aykjParentPid) {
this.aykjParentPid = aykjParentPid;
}
public Set getAykjChildrenId() {
return aykjChildrenId;
}
public void setAykjChildrenId(Set aykjChildrenId) {
this.aykjChildrenId = aykjChildrenId;
}

}

//产品属性
public class AykjProperties implements Serializable {
private int id;
private String name; //商品属性
private String description; //属性描述
private AykjProperties aykjparent; //父
private Set aykjchildren; //子
public int getId() {
return id;
}
public void setId(int 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 AykjProperties getAykjparent() {
return aykjparent;
}
public void setAykjparent(AykjProperties aykjparent) {
this.aykjparent = aykjparent;
}
public Set getAykjchildren() {
return aykjchildren;
}
public void setAykjchildren(Set aykjchildren) {
this.aykjchildren = aykjchildren;
}
}

//AykjProducterSort 配置文件














//AykjProperties 配置文件










[/code]
请问这样配置对不对
我要达到这样的目标:
因为一个产品可能有多少个属性
AykjProducterSort List producterSortProperties里面就要装下很多的AykjProperties (产品属性)
谢谢大家,帮我看下......

[b]问题补充:[/b]
火星,谢谢你,不过我那样设计是因为了好查数据的,我做的这个是商城可能有多要查询的地方..我现在也在考虑到底怎么设计数据.
[b]问题补充:[/b]
private String description; //属性描述

我把属性设计成树,是因为属性里面还有属性的,
比如说一个属性,年代
年代里面还有五十年代
六十年代等等的
[b]问题补充:[/b]
AykjProperties 这个类能不能分开,不和别的类有关系,别的类引用他就行了....

  • 写回答

5条回答 默认 最新

  • iteye_14081 2008-11-10 10:27
    关注

    [quote]AykjProperties 这个类能不能分开,不和别的类有关系,别的类引用他就行了....[/quote]
    也可以的,把AykjProperties里面的
    [code="java"]@ManyToOne(targetEntity = AykjProducterSort.class)

    private AykjProducterSort aykjProducterSort;//类别 [/code]
    删了就行了,也就是把关系维护在AykjProducterSort上。

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(4条)

报告相同问题?

悬赏问题

  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料