timestamp,datetime数据类型在ibatis中

本文探讨了在Ibatis中配置mysql数据库timestamp字段的方法,通过示例展示了如何正确映射Java日期类型到数据库timestamp或datetime类型。
mysql数据库字段为timestamp或datetime类型,在ibatis中不知道怎么配置,我用java.util.Date,和
java.sql.Timestamp都试过,都不行,不知道怎么解决,有人知道吗?谢谢!
[code] <resultMap id="forumResult" class="forum">
<result property="forumId" column="forumId" />
<result property="name" column="name" />
<result property="description" column="description" />
<result property="status" column="status" />
<result property="forumOrder" column="forumOrder" />
<result property="catId" column="catId" />
<result property="topicCount" column="topicCount" />
<result property="postCount" column="postCount" />
<result property="lastPostId" column="lastPostId" />
<result property="lastPoster" column="lastPoster" />
<result property="lastPostDate" column="lastPostDate"/>
<result property="lastTopicId" column="lastTopicId" />

</resultMap>

import java.util.Date;

public class Forum {

private Long forumId;

private String name;

private String description;

private int status;

private int forumOrder;

private int catId;

private int topicCount;

private int postCount;

private Long lastPostId;

private String lastPoster;

private Date lastPostDate;

private Long lastTopicId;

CREATE TABLE forum(
forumId bigint(20) unsigned NOT NULL AUTO_INCREMENT,
name varchar(200) DEFAULT NULL,
description varchar(200) DEFAULT NULL,
status int(2) unsigned DEFAULT NULL,
forumOrder int(2) unsigned DEFAULT NULL,
catId bigint(20) unsigned NOT NULL DEFAULT '0',
topicCount bigint(20) unsigned DEFAULT NULL,
postCount bigint(20) unsigned DEFAULT NULL,
lastPostId bigint(20) unsigned DEFAULT NULL,
lastPoster varchar(255) DEFAULT NULL,
lastPostDate datetime NOT NULL,
lastTopicId bigint(20) unsigned DEFAULT NULL,
PRIMARY KEY (forumId)
);
[/code]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值