Java tutorial
/* * Copyright 2005-2013 shopxx.net. All rights reserved. * Support: http://www.shopxx.net * License: http://www.shopxx.net/license */ package com.lingxiang2014.entity; import javax.persistence.Column; import javax.persistence.MappedSuperclass; import javax.validation.constraints.Min; import org.apache.commons.lang.builder.CompareToBuilder; import org.hibernate.search.annotations.Field; import org.hibernate.search.annotations.Index; import org.hibernate.search.annotations.Store; import com.fasterxml.jackson.annotation.JsonProperty; @MappedSuperclass public abstract class OrderEntity extends BaseEntity implements Comparable<OrderEntity> { private static final long serialVersionUID = 5995013015967525827L; public static final String ORDER_PROPERTY_NAME = "order"; private Integer order; @JsonProperty @Field(store = Store.YES, index = Index.UN_TOKENIZED) @Min(0) @Column(name = "orders") public Integer getOrder() { return order; } public void setOrder(Integer order) { this.order = order; } public int compareTo(OrderEntity orderEntity) { return new CompareToBuilder().append(getOrder(), orderEntity.getOrder()) .append(getId(), orderEntity.getId()).toComparison(); } }