Java inserts an Oracle database by mybatis The date format does not appear in the time and seconds issue

Source: Internet
Author: User
Tags time and seconds

After I generate the code with MyBatis generator, the Date Type field in Oracle is only accurate until the date of year, followed by zero seconds, when executing the query statement.

Later discovered is jdbctype problem, change into jdbctype= "TIMESTAMP" can. (previous default build is Jdbctype= "DATE")

PS: Entity class date is in the Java.util.Date bag, not java.sql.Date, otherwise it will only be accurate to the date of year


Entity classes

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;
    The public void Setcalltime (Date calltime) {this.calltime = Calltime;
    Public String Getinputparam () {return inputparam; } public void Setinputparam (String inputparam) {This.inputparam = Inputparam = = null? null:inputparam.tri
   M (); Public String Getoutputparam () {return outputparam; } public void Setoutputparam (String outputparam) {This.outputparam = Outputparam = = null? Null:outputpara
    M.trim ();
    Public String GetType () {return type;
    The 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 (); }
}

XML file

<?xml version= "1.0" encoding= "UTF-8"?> <! DOCTYPE Mapper Public "-//mybatis.org//dtd mapper 3.0//en" "Http://mybatis.org/dtd/mybatis-3-mapper.dtd" > < Mapper namespace= "Com.pcmall.dao.sale.erps.SynnexlogsMapper" > <resultmap id= "Baseresultmap"
    Com.pcmall.domain.sale.erps.Synnexlogs "> <result column=" SENDER property= "SENDER" jdbctype= "VARCHAR"/> <result column= "RECEIVER" property= "RECEIVER" jdbctype= "VARCHAR"/> <result column= "calltime" property= "call Time "jdbctype=" TIMESTAMP "/> <result column=" Inputparam "property=" Inputparam "jdbctype=" VARCHAR "  ; result column= ' Outputparam ' property= ' outputparam ' jdbctype= ' VARCHAR '/> <result ' column= ' type ' property= ' type '
  Jdbctype= "VARCHAR"/> <result column= "remark" property= "remark" jdbctype= "VARCHAR"/> </resultMap> <insert id= "Insert" parametertype= "Com.pcmall.domain.sale.erps.Synnexlogs" > INSERT into Synnexlogs (SENDER, RECEIVER, Calltime, Inputparam, Outputparam, TYPE, remark) VALUES (#{sender,jdbctype=varchar}, #{receiv Er,jdbctype=varchar}, #{calltime,jdbctype=timestamp}, #{inputparam,jdbctype=varchar}, #{outputparam,jdbcType=  VARCHAR}, #{type,jdbctype=varchar}, #{remark,jdbctype=varchar}) </insert> <insert id= "Insertselective"  Parametertype= "Com.pcmall.domain.sale.erps.Synnexlogs" > INSERT INTO Synnexlogs <trim prefix= "(" suffix= ")" Suffixoverrides= "," > <if test= "sender!= Null" > sender, </if> <if test= "Rec
      Eiver!= Null "> RECEIVER, </if> <if test=" calltime!= null "> Calltime, </if> <if test= "Inputparam!= null" > Inputparam, </if> <if test= "Outputpar AM!= Null "> Outputparam, </if> <if test=" type!= null "> Type, </if&
      Gt <if test= "Remark!= NULL "> Remark, </if> </trim> <trim prefix=" VALUES ("suffix=") "Suffixoverride S= "," > <if test= "sender!= null" > #{sender,jdbctype=varchar}, </if> <if test 
        = "receiver!= null" > #{receiver,jdbctype=varchar}, </if> <if test= "calltime!= null" > #{calltime,jdbctype=timestamp}, </if> <if test= "Inputparam!= null" > #{inputpara M,jdbctype=varchar}, </if> <if test= "Outputparam!= null" > #{outputparam,jdbctype=varchar }, </if> <if test= "type!= null" > #{type,jdbctype=varchar}, </if> <i F test= "remark!= null" > #{remark,jdbctype=varchar}, </if> </trim> </insert> ;/mapper>



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.