hibernate枚举映射成varchar,type设置了12,数据库还是int值,求大佬指教

自傷無色丶 2017-08-10 03:57:54
枚举:
package com.wego.domain;

public enum CustomerStage {
CustomerFocus("意向关注",1,"次",true),
CustomerCommunication("意向沟通",5,"次",true),
ClearIntention("意向明确重点跟踪",10,"次",true),
PreOrders("预定评估",20,"次",true),
ProductOrder("客户订单",25,"次",true),
Order("订单",990,"顶",false),
GiveUpDOcumentary("放弃跟单",999,"",true),
;
//中文名称
private String type;
//排序,阶段排序
private int index;
//单位
private String unit;
//标识
private boolean viewFlag;

private CustomerStage(String type,int index,String unit,boolean viewFlag){
this.type=type;
this.index=index;
this.unit=unit;
this.viewFlag=viewFlag;
}

public String getType() {
return type;
}

public void setType(String type) {
this.type = type;
}

public int getIndex() {
return index;
}

public void setIndex(int index) {
this.index = index;
}

public String getUnit() {
return unit;
}

public void setUnit(String unit) {
this.unit = unit;
}

public boolean isViewFlag() {
return viewFlag;
}

public void setViewFlag(boolean viewFlag) {
this.viewFlag = viewFlag;
}


}


映射文件
<hibernate-mapping package="com.wego.domain">
<class name="CustomerInfo" table="t_customer_customerinfo">
<id name="customerid" column="customerId">
<generator class="native"></generator>
</id>

<property name="customerStage" column="customerStage" length="20">
<type name="org.hibernate.type.EnumType">
<param name="enumClass">com.wego.domain.CustomerStage</param>
<param name="type">12</param>
</type>
</property>
...全文
167 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
自傷無色丶 2017-08-13
  • 打赏
  • 举报
回复
已解决,数据库编码问题,在spring配置数据源jdbcurl后面没有加编码参数,很奇怪,同样是在sqlserver就可以,在Mysql就得加
自傷無色丶 2017-08-10
  • 打赏
  • 举报
回复
求大佬指点下,很急啊
自傷無色丶 2017-08-10
  • 打赏
  • 举报
回复
数据库表ddl:
CREATE TABLE `t_customer_customerinfo` (
  `customerId` int(11) NOT NULL AUTO_INCREMENT,
  `customerStage` int(11) DEFAULT NULL,
  `orgId` int(11) DEFAULT NULL,
  PRIMARY KEY (`customerId`),
  KEY `FKkn75tso3sqx0qayd4g61fymak` (`orgId`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

81,091

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧