惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

美团技术团队
罗磊的独立博客
SecWiki News
SecWiki News
The Register - Security
The Register - Security
The GitHub Blog
The GitHub Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - 三生石上(FineUI控件)
S
Schneier on Security
IT之家
IT之家
博客园 - 聂微东
T
The Exploit Database - CXSecurity.com
Recorded Future
Recorded Future
大猫的无限游戏
大猫的无限游戏
Know Your Adversary
Know Your Adversary
Latest news
Latest news
Vercel News
Vercel News
G
GRAHAM CLULEY
D
DataBreaches.Net
D
Darknet – Hacking Tools, Hacker News & Cyber Security
S
SegmentFault 最新的问题
博客园_首页
雷峰网
雷峰网
T
Tenable Blog
Spread Privacy
Spread Privacy
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
酷 壳 – CoolShell
酷 壳 – CoolShell
Cisco Talos Blog
Cisco Talos Blog
V
Visual Studio Blog
J
Java Code Geeks
博客园 - Franky
The Cloudflare Blog
Apple Machine Learning Research
Apple Machine Learning Research
C
CERT Recently Published Vulnerability Notes
T
Threatpost
Google DeepMind News
Google DeepMind News
F
Fortinet All Blogs
P
Privacy International News Feed
T
Threat Research - Cisco Blogs
T
The Blog of Author Tim Ferriss
V
Vulnerabilities – Threatpost
Recent Announcements
Recent Announcements
Blog — PlanetScale
Blog — PlanetScale
Security Latest
Security Latest
U
Unit 42
M
MIT News - Artificial intelligence
Y
Y Combinator Blog
K
Kaspersky official blog
有赞技术团队
有赞技术团队
B
Blog
腾讯CDC

博客园 - 风歌

Sublimetext (for windows)编译运行c出现Error 2错误的解决办法 vim和tmux主题颜色不一致问题 vim安装YouCompleteMe 插件 perl在命令行中打印单引号 UTL_FILE建文件失败“ORA-29280: 目录路径无效”错误 openVPN报错:All TAP-Windows adapters on this system are currently in use - 风歌 xampp连接Admin界面报错 一个换行符引发的问题 如何把excel数据导入数据库 vmware给linux虚拟机增加磁盘空间(基于lvm分区) 带统一认证的轻量级网关系统 ORA-02292主键约束问题 curl遇到longjmp causes uninitialized stack frame的处理办法 ACE6.10的安装 redhat6.3企业版安装oracle11g过程 ld编译链接时默认搜索路径 vsftpd的安装及使用问题 Fedora core 6上安装vmeare-tools VIM7.0安装
hibernate date类型插入数据库时精度只到日期没有时间
风歌 · 2014-03-28 · via 博客园 - 风歌

由hibernate 的逆向工具从数据库表生成的*.hbm.xml ,对于数据库的date类型生成如下:

       <property name = "crttime" type= "date">

            <column name = "CRTTIME" length = "7"  />

        </property >

程序中的类型:

private Date crttime ;

但通过程序setCrttime(new Date()) 的时候,插入到数据库的日期只到天,没有小时以后的数据。

网上查了一下,有的说可以修改type类型为 java.util.Date, 但实验发现hibernate不能识别此类型,修改为timestamp则可以。

如下是最终修改:

        <property name ="crttime" type="timestamp">

            <column name ="CRTTIME"   />

        </property >

我把length = "7" 也去掉了