hibernate的问题

pangyunlong 2010-04-15 01:30:07
实体:
public class Party {
private Integer id;
private PartyType type;// 类型 many-to-one
private boolean status;
private Party parent;// 父节点

private Set<Party> children = new HashSet<Party>();// 子节点
private Timestamp formTime;// 起始时间
private Timestamp thruTime;// 过期时间
private String note;
private User user;
private UserInformation userInformation;
private Set<Order> orders;

public Integer getId() {
return id;
}

public void setId(Integer id) {
this.id = id;
}

public PartyType getType() {
return type;
}

public void setType(PartyType type) {
this.type = type;
}

public boolean isStatus() {
return status;
}

public void setStatus(boolean status) {
this.status = status;
}

public Party getParent() {
return parent;
}

public void setParent(Party parent) {
this.parent = parent;
}

public Set<Party> getChildren() {
return children;
}

public void setChildren(Set<Party> children) {
this.children = children;
}

public Timestamp getFormTime() {
return formTime;
}

public void setFormTime(Timestamp formTime) {
this.formTime = formTime;
}

public Timestamp getThruTime() {
return thruTime;
}

public void setThruTime(Timestamp thruTime) {
this.thruTime = thruTime;
}

public String getNote() {
return note;
}

public void setNote(String note) {
this.note = note;
}

public User getUser() {
return user;
}

public void setUser(User user) {
this.user = user;
}

public UserInformation getUserInformation() {
return userInformation;
}

public void setUserInformation(UserInformation userInformation) {
this.userInformation = userInformation;
}

public Set<Order> getOrders() {
return orders;
}

public void setOrders(Set<Order> orders) {
this.orders = orders;
}

}


映射文件
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="com.flight.domain">
<class name="Party" table="party">
<id name="id" type="integer" column="pid">
<generator class="native" />
</id>
<property name="status" type="java.lang.Boolean">
<column name="status" not-null="true" />
</property>


<property name="formTime" type="timestamp">
<column name="formTime" not-null="true" />
</property>
<property name="thruTime" type="timestamp">
<column name="thruTime" not-null="true" />
</property>
<property name="note" type="string">
<column name="note" not-null="true" length="200"/>
</property>

<one-to-one name="user" class="User" cascade="all" ></one-to-one>
<one-to-one name="userInformation" class="UserInformation" cascade="all"></one-to-one>
<many-to-one name="parent" column="parentId"/>
<set name="children" lazy="false">
<key column="parentId"/>
<one-to-many class="Party"/>
</set>
<many-to-one name="type" class="PartyType" column="ptid" cascade="save-update" lazy="false"/>
<set name="orders" lazy="extra" inverse="true">
<key column="pid"/>
<one-to-many class="Order"/>
</set>
</class>
</hibernate-mapping>


现在要设计业务方法,取出一个节点的所有子节点。各位大侠请指教
...全文
86 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
bunrise 2010-04-15
  • 打赏
  • 举报
回复
你既然都得到了Party
那么party.getChildren()就是下面的子节点了

如果还需要他下面的下面
那就递归循环children
pangyunlong 2010-04-15
  • 打赏
  • 举报
回复
假如现在有个Party 怎么获得它下面的所有子节点?代码示例
dobe1987 2010-04-15
  • 打赏
  • 举报
回复
解析XML
pangyunlong 2010-04-15
  • 打赏
  • 举报
回复
没人啊

67,538

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧