com.eryansky.entity.sys.Dictionary.java Source code

Java tutorial

Introduction

Here is the source code for com.eryansky.entity.sys.Dictionary.java

Source

/**
 *  Copyright (c) 2012-2014 http://www.eryansky.com
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 */
package com.eryansky.entity.sys;

import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.google.common.collect.Lists;
import com.eryansky.common.orm.entity.BaseEntity;
import com.eryansky.utils.CacheConstants;

/**
 * ?Entity.
 * 
 * @author : &Eryan eryanwcp@gmail.com
 * @date : 2013-1-23 ?9:08:36
 */

@Entity
@Table(name = "T_SYS_DICTIONARY")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE, region = CacheConstants.HIBERNATE_CACHE_SYS)
// jackson??json
@JsonIgnoreProperties(value = { "hibernateLazyInitializer", "handler", "fieldHandler", "parentDictionary",
        "dictionaryType", "subDictionarys" })
@SuppressWarnings("serial")
public class Dictionary extends BaseEntity {

    /**
     * ???
     */
    private String name;
    /**
     * ??
     */
    private String code;
    /**
     * ?
     */
    private String value;
    /**
     * 
     */
    private String remark;
    /**
     * ?
     */
    private Integer orderNo;
    /**
     * ?
     */
    private Dictionary parentDictionary;
    /**
     * ?Dictionary? @Transient
     */
    private List<Dictionary> subDictionarys = Lists.newArrayList();

    /**
     * ? @Transient
     */
    private String parentDictionaryCode;
    /**
     * ?? @Transient
     */
    private String parentDictionaryName;

    /**
     * 
     */
    private DictionaryType dictionaryType;

    /**
     *  ?code @Transient
     */
    private String dictionaryTypeCode;

    /**
     *  ??name @Transient
     */
    private String dictionaryTypeName;

    public Dictionary() {
    }

    @Column(name = "NAME", length = 100, unique = true)
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Column(name = "CODE", length = 36, unique = true)
    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    @Column(name = "VALUE", length = 100)
    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    @Column(name = "REMAK", length = 100)
    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;
    }

    @ManyToOne(cascade = { CascadeType.PERSIST, CascadeType.MERGE })
    @JoinColumn(name = "PARENT_CODE", referencedColumnName = "CODE")
    public Dictionary getParentDictionary() {
        return parentDictionary;
    }

    public void setParentDictionary(Dictionary parentDictionary) {
        this.parentDictionary = parentDictionary;
    }

    // @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy =
    // "parentDictionary")
    // @OrderBy("orderNo asc")
    // @LazyCollection(LazyCollectionOption.FALSE)
    @Transient
    public List<Dictionary> getSubDictionarys() {
        return subDictionarys;
    }

    public void setSubDictionarys(List<Dictionary> subDictionarys) {
        this.subDictionarys = subDictionarys;
    }

    @ManyToOne(cascade = { CascadeType.PERSIST, CascadeType.MERGE })
    @JoinColumn(name = "DICTIONARYTYPE_CODE", referencedColumnName = "CODE")
    public DictionaryType getDictionaryType() {
        return dictionaryType;
    }

    public void setDictionaryType(DictionaryType dictionaryType) {
        this.dictionaryType = dictionaryType;
    }

    @Transient
    public String getParentDictionaryCode() {
        if (StringUtils.isBlank(parentDictionaryCode) && parentDictionary != null) {
            parentDictionaryCode = parentDictionary.getCode();
        }
        return parentDictionaryCode;
    }

    public void setParentDictionaryCode(String parentDictionaryCode) {
        this.parentDictionaryCode = parentDictionaryCode;
    }

    @Transient
    public String getParentDictionaryName() {
        if (parentDictionary != null) {
            parentDictionaryName = parentDictionary.getName();
        }
        return parentDictionaryName;
    }

    public void setParentDictionaryName(String parentDictionaryName) {
        this.parentDictionaryName = parentDictionaryName;
    }

    @Transient
    public String getDictionaryTypeCode() {
        if (StringUtils.isBlank(dictionaryTypeCode) && dictionaryType != null) {
            dictionaryTypeCode = dictionaryType.getCode();
        }
        return dictionaryTypeCode;
    }

    public void setDictionaryTypeCode(String dictionaryTypeCode) {
        this.dictionaryTypeCode = dictionaryTypeCode;
    }

    @Transient
    public String getDictionaryTypeName() {
        if (dictionaryType != null) {
            dictionaryTypeName = dictionaryType.getName();
        }
        return dictionaryTypeName;
    }

    public void setDictionaryTypeName(String dictionaryTypeName) {
        this.dictionaryTypeName = dictionaryTypeName;
    }
}