PO实现hashCode()方法了没有?实现这个方法能够按方法中的字段排序,你试试。
package net.xsbn.stride.model.realm;
import java.util.Set;
import net.xsbn.stride.model.BaseObject;
import org.apache.commons.lang.builder.CompareToBuilder;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;
/**
* 模块(module)实体设计类.
* @author villion
* @hibernate.class table="usr_module"
*/
public class Module extends BaseObject implements Comparable {
/**
* 模块ID, 主键.
*/
private String id;
/**
* 模块名称.
*/
private String moduleName;
/**
* 模块的默认链接.
*/
private String moduleURL;
/**
* 模块图标.
*/
private String moduleIcon;
/**
* 说明.
*/
private String description;
/**
* 模块顺序.
*/
private int moduleOrder;
/**
* 隐藏模块.
* 默认为false,此模块会进行显示.
*/
private boolean hidden;
/**
* 模块非授权.
* 默认为false,必须进行授权管理.
*/
private boolean nonPermit;
/**
* 父模块.
*/
private Module parent;
/**
* 包含操作员.
*/
private Set operators;
/**
* 所属操作组.
*/
private Set groups;
/**
* 所属目录.
*/
private Catalog catalog;
/**
* 帮助文件地址
*/
private String helpUrl;
/**
* Access method for the id property.
*
* @return the current value of the id property
* @hibernate.id generator-class="uuid.hex" not-null="true"
*/
public String getId() {
return id;
}
/**
* Sets the value of the id property.
*
* @param aId the new value of the id property
*/
public void setId(String aId) {
id = aId;
}
/**
* Access method for the moduleName property.
*
* @return the current value of the moduleName property
* @hibernate.property column="modulename"
*/
public String getModuleName() {
return moduleName;
}
/**
* Sets the value of the moduleName property.
*
* @param aModuleName the new value of the moduleName property
*/
public void setModuleName(String aModuleName) {
moduleName = aModuleName;
}
/**
* Access method for the moduleURL property.
*
* @return the current value of the moduleURL property
* @hibernate.property column = "moduleURL"
*/
public String getModuleURL() {
return moduleURL;
}
/**
* Sets the value of the moduleURL property.
*
* @param aModuleURL the new value of the moduleURL property
*/
public void setModuleURL(String aModuleURL) {
moduleURL = aModuleURL;
}
/**
* Access method for the moduleIcon property.
*
* @return the current value of the moduleIcon property
* @hibernate.property column="moduleicon"
*/
public String getModuleIcon() {
return moduleIcon;
}
/**
* Sets the value of the moduleIcon property.
*
* @param aModuleIcon the new value of the moduleIcon property
*/
public void setModuleIcon(String aModuleIcon) {
moduleIcon = aModuleIcon;
}
/**
* Access method for the description property.
*
* @return the current value of the description property
* @hibernate.property
*/
public String getDescription() {
return description;
}
/**
* Sets the value of the description property.
*
* @param aDescription the new value of the description property
*/
public void setDescription(String aDescription) {
this.description = aDescription;
}
/**
* @return Returns the moduleOrder.
* @hibernate.property column="moduleorder" not-null = "true"
*/
public int getModuleOrder() {
return moduleOrder;
}
/**
* @param moduleOrder The moduleOrder to set.
*/
public void setModuleOrder(int moduleOrder) {
this.moduleOrder = moduleOrder;
}
/**
* @return Returns the hidden.
* @hibernate.property column = "ishidden"
*/
public boolean isHidden() {
return hidden;
}
/**
* @param hidden The hidden to set.
*/
public void setHidden(boolean hidden) {
this.hidden = hidden;
}
/**
* @return Returns the nonPermit.
* @hibernate.property column = "isnonpermit"
*/
public boolean isNonPermit() {
return nonPermit;
}
/**
* @param nonPermit The nonPermit to set.
*/
public void setNonPermit(boolean nonPermit) {
this.nonPermit = nonPermit;
}
/**
* @return Returns the parentId.
* @hibernate.many-to-one column="parentid"
* class="net.xsbn.stride.model.realm.Module"
*/
public Module getParent() {
return parent;
}
/**
* @param parentId The parentId to set.
*/
public void setParent(Module parentId) {
this.parent = parentId;
}
/**
* @return Returns the operators.
* @hibernate.set table="usr_operator_module" lazy="true"
* @hibernate.collection-key column="moduleid"
* @hibernate.collection-many-to-many column="userid"
* class="net.xsbn.stride.model.realm.Operator"
*/
public Set getOperators() {
return operators;
}
/**
* @param operators The operators to set.
*/
public void setOperators(Set operators) {
this.operators = operators;
}
/**
* @return Returns the groups.
* @hibernate.set table="usr_group_module" lazy="true"
* @hibernate.collection-key column="moduleid"
* @hibernate.collection-many-to-many column="groupid"
* class="net.xsbn.stride.model.realm.Group"
*/
public Set getGroups() {
return groups;
}
/**
* @param groups The groups to set.
*/
public void setGroups(Set groups) {
this.groups = groups;
}
/**
* @return Returns the catalog.
* @hibernate.many-to-one column="catalogid"
* class="net.xsbn.stride.model.realm.Catalog"
*/
public Catalog getCatalog() {
return catalog;
}
/**
* @param catalog The catalog to set.
*/
public void setCatalog(Catalog catalog) {
this.catalog = catalog;
}
public String toString() {
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
.append(this.id)
.append(this.moduleName)
.toString();
}
public boolean equals(Object o) {
try {
Module c = (Module) o;
return new EqualsBuilder()
.append(this.id, c.id)
.append(this.moduleName, c.moduleName)
.isEquals();
}
catch(Exception ex) {
//ex.printStackTrace();
return false;
}
}
public int hashCode() {
return new HashCodeBuilder()
.append(this.id)
.append(this.moduleName)
.toHashCode();
}
/* (non-Javadoc)
* @see java.lang.Comparable#compareTo(java.lang.Object)
*/
public int compareTo(Object o) {
Module m = (Module) o;
return new CompareToBuilder()
.append(this.moduleOrder, m.moduleOrder)
.toComparison();
}
/**
* @return Returns the helpUrl.
* @hibernate.property column="helpurl"
*/
public String getHelpUrl() {
return helpUrl;
}
/**
* @param helpUrl The helpUrl to set.
*/
public void setHelpUrl(String helpUrl) {
this.helpUrl = helpUrl;
}
}
<set
name="operators"
table="usr_operator_module"
lazy="true"
inverse="false"
cascade="none"
sort="unsorted"
>
<key
column="moduleid"
>
</key>
<many-to-many
class="net.xsbn.stride.model.realm.Operator"
column="userid"
outer-join="auto"
/>
</set>
<set
name="groups"
table="usr_group_module"
lazy="true"
inverse="false"
cascade="none"
sort="unsorted"
>
<key
column="moduleid"
>
</key>
<many-to-many
class="net.xsbn.stride.model.realm.Group"
column="groupid"
outer-join="auto"
/>
</set>
分享到:
相关推荐
Hibernate中对表某个字段排序,直接在配置里面实现排序功能。
hibernate criteria 分组 排序 关联 hibernate criteria 分组 排序 关联
Hibernate Criteria 排序的問題
这是Java常用框架阶段在为学生答疑时做的一个SSH整合分页实例(第一部分),涉及了SSH整合、日期模糊查询、查询条件绑定、查询结果排序等功能,希望能为大家提供一些思路。 分页是绝大多数MIS系统必需的功能之一,...
LIST对象排序通用方法HIBERNATE的SET排序.pdf
NULL 博文链接:https://raywithu.iteye.com/blog/1139332
spring,hibernate之服务器端分页,排序,spring,hibernate之服务器端分页,排序
分析LIST对象排序通用方法HIBERNATE的SET排序.pdf
通过 PostMan 等 RestClient 将待排序的多个数值发给 RestServer,RestServer 对这些数值进行排序,将排序前和排序后的数值存入数据库(可以是MySQL/H2等),并将排序结果返回给 RestClient。如果对 SpringBoot/...
LIST对象排序通用方法HIBERNATE的SET排序[整理].pdf
等通配符号),多关键字,模糊查询,排序等6,支持Clustering7,支持直接访问Lucene API8,对Lucene索引,API的高效管理Hibernate Search运行的环境如下:1、JDK或JRE 5.0以上2、Hibernate-Search以及相应的依赖包3...
Hibernate一对多多对多查询的排序.doc
15.3. 结果集排序 15.4. 关联 15.5. 动态关联抓取 15.6. 查询示例 15.7. 投影(Projections)、聚合(aggregation)和分组(grouping) 15.8. 离线(detached)查询和子查询 15.9. 根据自然标识查询(Queries by ...
对结果排序 12.4. 关联(Associations) 12.5. 动态关联对象获取(Dynamic association fetching) 12.6. 根据示例查询(Example queries) 13. 原生SQL查询 13.1. 创建一个基于SQL的Query 13.2....
15.3. 结果集排序 15.4. 关联 15.5. 动态关联抓取 15.6. 查询示例 15.7. 投影(Projections)、聚合(aggregation)和分组(grouping) 15.8. 离线(detached)查询和子查询 15.9. 根据自然标识查询(Queries by ...
第一部分 从Hibernate和EJB 3.0开始 第1章 理解对象/关系持久化 1.1 什么是持久化 1.1.1 关系数据库 1.1.2 理解SQL 1.1.3 在Java中使用SQL 1.1.4 面向对象应用程序中的持久化 1.2 范式不...
15.3. 结果集排序 15.4. 关联 15.5. 动态关联抓取 15.6. 查询示例 15.7. 投影(Projections)、聚合(aggregation)和分组(grouping) 15.8. 离线(detached)查询和子查询 15.9. 根据自然标识查询(Queries by ...
17.1.7 对查询结果排序 17.1.8 分页查询 17.1.9 检索单个对象(uniqueResult()方法) 17.1.10 按主键逐个处理查询结果(iterate()方法) 17.1.11 可滚动的结果集 17.1.12 在HQL查询语句中绑定参数 ...
hibernate分页(无排序,搜索,仅仅分页显示),服务器端分页在datatables上展现,有关 datatables的知识请关注它的官网http://www.datatables.net/,datatables的功能很 全面。 2,建表的sql--studentinfo和插入...
15.3. 结果集排序 15.4. 关联 15.5. 动态关联抓取 15.6. 查询示例 15.7. 投影(Projections)、聚合(aggregation)和分组(grouping) 15.8. 离线(detached)查询和子查询 15.9. 根据自然标识查询(Queries by natural ...