实体:
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>
现在要设计业务方法,取出一个节点的所有子节点。各位大侠请指教
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>
现在要设计业务方法,取出一个节点的所有子节点。各位大侠请指教
解决方案 »
- JSF+Srping整合问题,高分求助
- Servlet+Javabean+MVC的简单语句
- weblogic上部署多个web应用如何配置各自的log4j.properties
- POI生成Excel,打开生成的Excel文件损坏!【急】
- hibnertate 的映射关联怎么自动生成的?
- JNI 在jsp下到底该如何调用
- 怎么通过地址栏传参实现让已经写好的jsp页面出来
- 如果将bean:write中打印出来的值转换格式
- 电子邮件问题?
- 急!!!!!在linux下安装tomcat不能绑定到80端口!!!!
- struts2类型转换与校验框架不能同时用?????
- ssh整合tomcat启动报错UnabletolocateSpringNamespaceHandlerforXMLschemanamespace
那么party.getChildren()就是下面的子节点了如果还需要他下面的下面
那就递归循环children