67,549
社区成员




<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="com.ffcs.cip.entity.ShopDict" table="cip_shop_dict">
<id name="id" type="java.lang.Integer">
<column name="id" />
<generator class="identity" />
</id>
<many-to-one name="parent" class="com.ffcs.cip.entity.ShopDict" column="parent_id" />
<property name="name" type="java.lang.String">
<column name="name" length="50" />
</property>
<property name="orderId" type="java.lang.Integer">
<column name="order_id" />
</property>
<set name="childs" inverse="true" cascade="all-delete-orphan" lazy="true" table="cip_shop_dict">
<key column="parent_id"/>
<one-to-many class="com.ffcs.cip.entity.ShopDict"/>
</set>
</class>
</hibernate-mapping>
package com.ffcs.cip.entity;
import java.io.Serializable;
import java.util.Set;
/**
*
* 店铺字典信息
* @Copyright: Copyright (c) 2011 FFCS All Rights Reserved
* @Company: 北京福富软件有限公司
* @author 阮张忠 2011-09-26
* @version 1.00.00
* @history:
*
*/
public class Dict implements Serializable{
private static final long serialVersionUID = -3046741248076639964L;
public Dict() {
}
public Dict(Integer id, ShopDict parent, String name, Integer orderId) {
this.id = id;
this.parent = parent;
this.name = name;
this.orderId = orderId;
}
/**
* 主键
*/
private Integer id;
/**
* 父节点
*/
private ShopDict parent;
/**
* 字典名称
*/
private String name;
/**
* 排序
*/
private Integer orderId;
/**
* 子节点集
*/
private Set<ShopDict> childs;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public ShopDict getParent() {
return parent;
}
public void setParent(ShopDict parent) {
this.parent = parent;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Integer getOrderId() {
return orderId;
}
public void setOrderId(Integer orderId) {
this.orderId = orderId;
}
public Set<ShopDict> getChilds() {
return childs;
}
public void setChilds(Set<ShopDict> childs) {
this.childs = childs;
}
}
@Override
public void deleteById(Integer id) {
if ( id == null || id < 1 ) {
return;
}
StringBuilder hql=new StringBuilder("delete ShopDict bean where bean.id=:id");
Query query = this.getSession().createQuery(hql.toString());
query.setInteger("id", id);
query.executeUpdate();
}