Java tutorial
/** * Copyright (c) 2012-2014 http://www.eryansky.com * * Licensed under the Apache License, Version 2.0 (the "License"); */ package com.eryansky.entity.sys; import javax.persistence.*; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import com.google.common.collect.Lists; import org.apache.commons.lang3.builder.ToStringBuilder; import org.hibernate.annotations.Cache; import org.hibernate.annotations.CacheConcurrencyStrategy; import com.eryansky.common.excel.annotation.Excel; import com.eryansky.common.orm.entity.BaseEntity; import com.eryansky.utils.CacheConstants; import java.util.List; /** * Entity. * * @author : &Eryan eryanwcp@gmail.com * @date : 2013-1-23 ?9:08:36 */ @Entity @Table(name = "T_SYS_DICTIONARYTYPE") @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE, region = CacheConstants.HIBERNATE_CACHE_SYS) @JsonIgnoreProperties(value = { "hibernateLazyInitializer", "handler", "fieldHandler", "groupDictionaryType", "subDictionaryTypes" }) @SuppressWarnings("serial") public class DictionaryType extends BaseEntity { /** * ?? */ @Excel(exportName = "??", exportFieldWidth = 30) private String name; /** * ? */ @Excel(exportName = "?", exportFieldWidth = 20) private String code; /** * ? */ private DictionaryType groupDictionaryType; /** * @Transient ??? */ private String groupDictionaryTypeName; /** * @Transient ?? */ private String groupDictionaryTypeCode; /** * ?DictionaryType? */ private List<DictionaryType> subDictionaryTypes = Lists.newArrayList(); /** * */ private String remark; /** * ? */ @Excel(exportName = "?", exportFieldWidth = 10) private Integer orderNo; public DictionaryType() { super(); } /** * ?. * * @param name * ?? * @param code * ? * @param orderNo * ? */ public DictionaryType(String name, String code, Integer orderNo) { super(); this.name = name; this.code = code; this.orderNo = orderNo; } @Column(name = "NAME", length = 100, unique = true) public String getName() { return name; } public void setName(String name) { this.name = name; } @Column(name = "CODE", length = 20, unique = true) public String getCode() { return code; } public void setCode(String code) { this.code = code; } @ManyToOne(cascade = { CascadeType.PERSIST, CascadeType.MERGE }) @JoinColumn(name = "GROUP_CODE", referencedColumnName = "CODE") public DictionaryType getGroupDictionaryType() { return groupDictionaryType; } public void setGroupDictionaryType(DictionaryType groupDictionaryType) { this.groupDictionaryType = groupDictionaryType; } @Transient public String getGroupDictionaryTypeName() { if (groupDictionaryType != null) { groupDictionaryTypeName = groupDictionaryType.getName(); } return groupDictionaryTypeName; } public void setGroupDictionaryTypeName(String groupDictionaryTypeName) { this.groupDictionaryTypeName = groupDictionaryTypeName; } @Transient @JsonProperty("_parentId") public String getGroupDictionaryTypeCode() { if (groupDictionaryType != null) { groupDictionaryTypeCode = groupDictionaryType.getCode(); } return groupDictionaryTypeCode; } public void setGroupDictionaryTypeCode(String groupDictionaryTypeCode) { this.groupDictionaryTypeCode = groupDictionaryTypeCode; } @OneToMany(mappedBy = "groupDictionaryType") public List<DictionaryType> getSubDictionaryTypes() { return subDictionaryTypes; } public void setSubDictionaryTypes(List<DictionaryType> subDictionaryTypes) { this.subDictionaryTypes = subDictionaryTypes; } @Column(name = "REMARK") public String getRemark() { return remark; } public void setRemark(String remark) { this.remark = remark; } @Column(name = "ORDER_NO") public Integer getOrderNo() { return orderNo; } public void setOrderNo(Integer orderNo) { this.orderNo = orderNo; } }