我在用mybatis generator生成代码后,执行查询语句时,Oracle里的Date类型字段只精确到年月日,后面时分秒都为零。
后来发现是jdbcType问题,改成 jdbcType="TIMESTAMP" 就可以。(原先默认生成时是jdbcType="DATE")
ps:实体类里Date是Java.util.Date包里的,不是java.sql.Date,否则也会只精确到年月日
实体类
package com.pcmall.domain.sale.erps;
import java.util.Date;
public class Synnexlogs {
private String sender;
private String receiver;
private Date calltime;
private String inputparam;
private String outputparam;
private String type;
private String remark;
public String getSender() {
return sender;
}
public void setSender(String sender) {
this.sender = sender == null ? null : sender.trim();
}
public String getReceiver() {
return receiver;
}
public void setReceiver(String receiver) {
this.receiver = receiver == null ? null : receiver.trim();
}
public Date getCalltime() {
return calltime;
}
public void setCalltime(Date calltime) {
this.calltime = calltime;
}
public String getInputparam() {
return inputparam;
}
public void setInputparam(String inputparam) {
this.inputparam = inputparam == null ? null : inputparam.trim();
}
public String getOutputparam() {
return outputparam;
}
public void setOutputparam(String outputparam) {
this.outputparam = outputparam == null ? null : outputparam.trim();
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type == null ? null : type.trim();
}
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark == null ? null : remark.trim();
}
}
insert into SYNNEXLOGS (SENDER, RECEIVER, CALLTIME,
INPUTPARAM, OUTPUTPARAM, TYPE,
REMARK)
values (#{sender,jdbcType=VARCHAR}, #{receiver,jdbcType=VARCHAR}, #{calltime,jdbcType=TIMESTAMP},
#{inputparam,jdbcType=VARCHAR}, #{outputparam,jdbcType=VARCHAR}, #{type,jdbcType=VARCHAR},
#{remark,jdbcType=VARCHAR})
insert into SYNNEXLOGS
SENDER,
RECEIVER,
CALLTIME,
INPUTPARAM,
OUTPUTPARAM,
TYPE,
REMARK,
#{sender,jdbcType=VARCHAR},
#{receiver,jdbcType=VARCHAR},
#{calltime,jdbcType=TIMESTAMP},
#{inputparam,jdbcType=VARCHAR},
#{outputparam,jdbcType=VARCHAR},
#{type,jdbcType=VARCHAR},
#{remark,jdbcType=VARCHAR},