hibernate注解实现set集合排序

package com.dc.product.entity.res;

// Generated 2014-11-28 16:53:22 by Hibernate Tools 3.4.0.CR1

import java.math.BigDecimal;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OrderBy;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.hibernate.validator.Length;
import org.hibernate.validator.NotNull;

/**
 * ResourceGroupDef generated by hbm2java
 */
@Entity
@Table(name = "T_RES_RESOURCEGROUPDEF", schema = "PROD")
public class ResourceGroupDef implements java.io.Serializable {

	private String resourceGroup;
	private ResourceGroupDef resourceGroupDef;
	private ResourceClass resourceClass;
	private String groupName;
	private String groupAttr;
	private BigDecimal groupLevel;
	private BigDecimal displayOrder;
	private String modifyStaff;
	private Date modifyDate;
	private String remark;
	private Set<ResourceGroupDef> resourceGroupDefs = new HashSet<ResourceGroupDef>(
			0);
	private Set<ResourceBaseInfo> resourceBaseInfos = new HashSet<ResourceBaseInfo>(
			0);

	public ResourceGroupDef() {
	}

	public ResourceGroupDef(String resourceGroup, String groupName,
			String groupAttr, BigDecimal groupLevel, BigDecimal displayOrder) {
		this.resourceGroup = resourceGroup;
		this.groupName = groupName;
		this.groupAttr = groupAttr;
		this.groupLevel = groupLevel;
		this.displayOrder = displayOrder;
	}

	public ResourceGroupDef(String resourceGroup,
			ResourceGroupDef resourceGroupDef, ResourceClass resourceClass,
			String groupName, String groupAttr, BigDecimal groupLevel,
			BigDecimal displayOrder, String modifyStaff, Date modifyDate,
			String remark, Set<ResourceGroupDef> resourceGroupDefs,
			Set<ResourceBaseInfo> resourceBaseInfos) {
		this.resourceGroup = resourceGroup;
		this.resourceGroupDef = resourceGroupDef;
		this.resourceClass = resourceClass;
		this.groupName = groupName;
		this.groupAttr = groupAttr;
		this.groupLevel = groupLevel;
		this.displayOrder = displayOrder;
		this.modifyStaff = modifyStaff;
		this.modifyDate = modifyDate;
		this.remark = remark;
		this.resourceGroupDefs = resourceGroupDefs;
		this.resourceBaseInfos = resourceBaseInfos;
	}

	@Id
	@Column(name = "RESOURCE_GROUP", unique = true, nullable = false, length = 15)
	@NotNull
	@Length(max = 15)
	public String getResourceGroup() {
		return this.resourceGroup;
	}

	public void setResourceGroup(String resourceGroup) {
		this.resourceGroup = resourceGroup;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "UP_RESOURCE_GROUP")
	public ResourceGroupDef getResourceGroupDef() {
		return this.resourceGroupDef;
	}

	public void setResourceGroupDef(ResourceGroupDef resourceGroupDef) {
		this.resourceGroupDef = resourceGroupDef;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "RESOURCE_CLASS")
	public ResourceClass getResourceClass() {
		return this.resourceClass;
	}

	public void setResourceClass(ResourceClass resourceClass) {
		this.resourceClass = resourceClass;
	}

	@Column(name = "GROUP_NAME", nullable = false, length = 128)
	@NotNull
	@Length(max = 128)
	public String getGroupName() {
		return this.groupName;
	}

	public void setGroupName(String groupName) {
		this.groupName = groupName;
	}

	@Column(name = "GROUP_ATTR", length = 2)
	@NotNull
	@Length(max = 2)
	public String getGroupAttr() {
		return this.groupAttr;
	}

	public void setGroupAttr(String groupAttr) {
		this.groupAttr = groupAttr;
	}

	@Column(name = "GROUP_LEVEL", nullable = false, precision = 22, scale = 0)
	@NotNull
	public BigDecimal getGroupLevel() {
		return this.groupLevel;
	}

	public void setGroupLevel(BigDecimal groupLevel) {
		this.groupLevel = groupLevel;
	}

	@Column(name = "DISPLAY_ORDER", nullable = false, precision = 22, scale = 0)
	@NotNull
	public BigDecimal getDisplayOrder() {
		return this.displayOrder;
	}

	public void setDisplayOrder(BigDecimal displayOrder) {
		this.displayOrder = displayOrder;
	}

	@Column(name = "MODIFY_STAFF", length = 15)
	@Length(max = 15)
	public String getModifyStaff() {
		return this.modifyStaff;
	}

	public void setModifyStaff(String modifyStaff) {
		this.modifyStaff = modifyStaff;
	}

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "MODIFY_DATE", length = 7)
	public Date getModifyDate() {
		return this.modifyDate;
	}

	public void setModifyDate(Date modifyDate) {
		this.modifyDate = modifyDate;
	}

	@Column(name = "REMARK", length = 128)
	@Length(max = 128)
	public String getRemark() {
		return this.remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "resourceGroupDef")
	@OrderBy("displayOrder")
	public Set<ResourceGroupDef> getResourceGroupDefs() {
		return this.resourceGroupDefs;
	}

	public void setResourceGroupDefs(Set<ResourceGroupDef> resourceGroupDefs) {
		this.resourceGroupDefs = resourceGroupDefs;
	}

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "resourceGroupDef")
	public Set<ResourceBaseInfo> getResourceBaseInfos() {
		return this.resourceBaseInfos;
	}

	public void setResourceBaseInfos(Set<ResourceBaseInfo> resourceBaseInfos) {
		this.resourceBaseInfos = resourceBaseInfos;
	}

}

核心的部分:

@OneToMany(fetch = FetchType.LAZY, mappedBy = "resourceGroupDef")
	@OrderBy("displayOrder")
	public Set<ResourceGroupDef> getResourceGroupDefs() {
		return this.resourceGroupDefs;
	}


214222_vrL1_855386.png


214328_3wtQ_855386.png

转载于:https://my.oschina.net/u/855386/blog/351993

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值