首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 其他教程 > 开源软件 >

枚举门类映射配置(Annotation方式)

2012-06-29 
枚举类型映射配置(Annotation方式)??package com.vlives.boss.merchant.domain?@TypeDefs({ @TypeDef(nam

枚举类型映射配置(Annotation方式)

?

?

package com.vlives.boss.merchant.domain;

?

@TypeDefs({ @TypeDef(name = "status", typeClass = EnumType.class, parameters = { @Parameter(name = "class", value = "com.vlives.boss.merchant.domain.Merchant$Status") })

?

})

@Entity

@org.hibernate.annotations.Entity(mutable = false, dynamicUpdate = false, dynamicInsert = false)

@Table(name = "URMTMINF")

public class Merchant extends BaseEntity {

?

private String id;

?

private Merchant parent;

?

private Set<Merchant> childrens;

?

private Set<Pos> poses;

?

private Area area;

?

private String code;

?

private String name;

?

private Status status;

?

private String shortName;

?

private String englishName;

?

private String businessAddress;

?

private String businessAddressCode;

?

private String businessTelephone;

?

public static enum Status implements EnumTypeInterface {

?

STATUS_ACTIVE(0, "状态1"),

?

STATUS_DISABLE(1, "状态2"),

?

STATUS_DELETE(2, "状态3");

?

private int value;

private String desc;

?

Status(int value, String desc) {

this.value = value;

this.desc = desc;

}

?

public int getValue() {

return this.value;

}

?

public String getDesc() {

return this.desc;

}

?

public static Status get(int value) {

for (Status status : Status.values()) {

if (status.value == value) {

return status;

}

}

throw new IllegalArgumentException("argument error: " + value);

}

}

?

@Type(type = "status")

@Column(name = "MERC_STS")

public Status getStatus() {

return status;

}

?

public void setStatus(Status status) {

this.status = status;

}

? ? ? ? //other getter ?&& ?setter......?

}






public interface EnumTypeInterface {public int getValue();public String getDesc();}

热点排行