是否存在包含 Joda Time / iBATIS 集成类的库?
看来我必须为 DateTime 和 LocalDateTime Joda 类型实现 com.ibatis.sqlmap.client.extensions.TypeHandlerCallback 。这没什么大不了的,但如果它在其他地方实现,我宁愿只使用它。
It looks like I have to implement com.ibatis.sqlmap.client.extensions.TypeHandlerCallback for both DateTime and LocalDateTime Joda types. This isn't a big deal, but if it's implemented somewhere else I'd rather just use that.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在我看来,没有干净灵活的解决方案。 Jodatime 日期比 JDBC 本机类型(
java.sql.Date
、java.sql.Timestamp
...)更灵活,如果映射到它们,您可能会丢失信息(时区)。一个“完整”的实现(可能绕过 getDate()/getTimestamp() 等 JDBC 方法,例如使用字符串)将取决于您的 JDBC 驱动程序和数据库(以及实际上没有数据库的日期时间类型像 Jodatime 那样具有表现力)。这是我曾经为
LocalDateTime
做过的一个相当简单的实现。没有经过充分测试,它假设您的数据库时间戳代表本地日期时间。There are no clean and flexible solutions, IMO. Jodatime dates are more flexible than the JDBC native types (
java.sql.Date
,java.sql.Timestamp
...) and if you map to them you might be losing information (timezones). An "full" implementation, (perhaps bypassing thegetDate()
/getTimestamp()
etc JDBC methods, using strings for example) would depend on your JDBC driver and database (and practically no database has datetime type as expressive as Jodatime's).Here's a rather trivial implementation I did once for
LocalDateTime
. Not very tested, and it assumes your DB timestamps represent local datetimes.我会把它放在那里...我们刚刚移动了代码来为 iBatis 和 myBatis 执行此操作。正如每个人都提到的,由于 java.sql 包的限制,使用时区并不有趣。但是,至少可以通过 LocalDate 和 DateTime
请给予反馈!这个包还早
I'll put this out there... we just moved our code to do this for both iBatis and myBatis. As everyone has mentioned, timezones are not fun to work with because of the limitations in the java.sql package. However, it is possible with the proper setup at least with LocalDate and DateTime
Please give feedback! This package is early