问题描述
使用hibernate ..我正在学习技术..不知道我在哪里错了...请指导这一点。上面的错误,当试图从一个类型的数据库 - TIMESTAMP()的数据库映射到Pojo变量...我尝试将变量类型更改为日期...日历...时间戳..没有什么作品在这里...
问题似乎与列的映射...任何帮助,这是非常赞赏......
我pojo类:
public class Pojo _ ****
{.........
私人日期C_TimeStamp;
私人日期L_TimeStamp;
}
我的数据库表:
表_ ****
..........
C_TimeStamp TIMESTAMP(6)
L_TimeStamp TIMESTAMP(6)
我的配置xml:
Pojo _ ****。hbm.xml
......
< property name =L_TimeStampcolumn =L_TimeStamp/>
错误日志:
在MainApp的Main方法中...
2016年3月9日下午2时48分14秒org.hibernate.cfg.Environment< clinit>
INFO:Hibernate 3.2 cr4
三月9,2016 2:48:14 PM org.hibernate.cfg.Environment< clinit>
INFO:找不到hibernate.properties
Mar 9,2016 2:48:14 PM org.hibernate.cfg.Environment buildBytecodeProvider
INFO:字节码提供程序名称:cglib
Mar 9 ,2016 2:48:14 PM org.hibernate.cfg.Environment< clinit>
INFO:使用JDK 1.4 java.sql.Timestamp处理
3月9日,2016 2:48:15 PM org.hibernate.cfg.Configuration configure
INFO:从资源配置:hibernate.cfg .xml
Mar 9,2016 2:48:15 PM org.hibernate.cfg.Configuration getConfigurationInputStream
INFO:配置资源:hibernate.cfg.xml
Mar 9,2016 2:48: 15下午org.hibernate.cfg.Configuration addResource
INFO:从资源读取映射:Pojo _ ****。hbm.xml
Mar 9,2016 2:48:15 PM org.hibernate.cfg。 HbmBinder bindRootPersistentClassCommonValues
INFO:映射类:Pojo _ **** - >表_ ****
2016年3月9日下午2时48分15秒org.hibernate.cfg.Configuration doConfigure
INFO:配置SessionFactory:null
无法创建sessionFactory object.org.hibernate .MappingException:无法确定类型:Timestamp,列:[org.hibernate.mapping.Column(L_TimeStamp)]
线程main中的异常java.lang.ExceptionInInitializerError $ tutorialspoint.example中的
。 MainApp.main(MainApp.java:29)
导致:org.hibernate.MappingException:无法确定类型:时间戳,列:[org.hibernate.mapping.Column(L_TimeStamp)]
at org.hibernate.mapping.SimpleValue.getType(SimpleValue.java:266)
at org.hibernate.mapping.SimpleValue.isValid(SimpleValue.java:253)
at org.hibernate.mapping.Property .isValid(Property.java:185)
在org.hibernate.mapping.PersistentClass.validate(PersistentClass.java:410)
在org.hibernate.mapping.RootClass.validate(RootClass.java:192 )在org.hibernate.cfg.Configura上
tion.validate(Configuration.java:1026)
位于org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1211)
位于tutorialspoint.example.MainApp.main(MainApp.java:21)
您是否尝试添加type =timestamp你的.hbm.xml文件,像这样?
< property name =C_TimeStampcolumn =C_TimeStamptype =时间戳/>
据我所知Time在xml配置中不被视为基本类型,因此应该是映射文件。
Using hibernate.. I am learning the technology at the moment.. Not sure where I m wrong...Pls guide on this..
I see the above error when trying to map a column from db of type - TIMESTAMP() to Pojo variable...I tried changing the variable type to Date...Calendar...Timestamp.. Nothing works here...The issue is seems to be with the mapping for the column... Any help on this is much appreciated...
My pojo class:
public class Pojo_****
{ .........
private Date C_TimeStamp;
private Date L_TimeStamp;
}
My DB table:
Table_****
..........
C_TimeStamp TIMESTAMP(6)
L_TimeStamp TIMESTAMP(6)
My configuration xml:
Pojo_****.hbm.xml
......
<property name="C_TimeStamp" column="C_TimeStamp" />
<property name="L_TimeStamp" column="L_TimeStamp" />
Error Logs:
In Main method of MainApp...
Mar 9, 2016 2:48:14 PM org.hibernate.cfg.Environment <clinit>
INFO: Hibernate 3.2 cr4
Mar 9, 2016 2:48:14 PM org.hibernate.cfg.Environment <clinit>
INFO: hibernate.properties not found
Mar 9, 2016 2:48:14 PM org.hibernate.cfg.Environment buildBytecodeProvider
INFO: Bytecode provider name : cglib
Mar 9, 2016 2:48:14 PM org.hibernate.cfg.Environment <clinit>
INFO: using JDK 1.4 java.sql.Timestamp handling
Mar 9, 2016 2:48:15 PM org.hibernate.cfg.Configuration configure
INFO: configuring from resource: hibernate.cfg.xml
Mar 9, 2016 2:48:15 PM org.hibernate.cfg.Configuration getConfigurationInputStream
INFO: Configuration resource: hibernate.cfg.xml
Mar 9, 2016 2:48:15 PM org.hibernate.cfg.Configuration addResource
INFO: Reading mappings from resource: Pojo_****.hbm.xml
Mar 9, 2016 2:48:15 PM org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
INFO: Mapping class: Pojo_****-> Table_****
Mar 9, 2016 2:48:15 PM org.hibernate.cfg.Configuration doConfigure
INFO: Configured SessionFactory: null
Failed to create sessionFactory object.org.hibernate.MappingException: Could not determine type for: Timestamp, for columns: [org.hibernate.mapping.Column(L_TimeStamp)]
Exception in thread "main" java.lang.ExceptionInInitializerError
at tutorialspoint.example.MainApp.main(MainApp.java:29)
Caused by: org.hibernate.MappingException: Could not determine type for: Timestamp, for columns: [org.hibernate.mapping.Column(L_TimeStamp)]
at org.hibernate.mapping.SimpleValue.getType(SimpleValue.java:266)
at org.hibernate.mapping.SimpleValue.isValid(SimpleValue.java:253)
at org.hibernate.mapping.Property.isValid(Property.java:185)
at org.hibernate.mapping.PersistentClass.validate(PersistentClass.java:410)
at org.hibernate.mapping.RootClass.validate(RootClass.java:192)
at org.hibernate.cfg.Configuration.validate(Configuration.java:1026)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1211)
at tutorialspoint.example.MainApp.main(MainApp.java:21)
Did you try adding the type="timestamp" in your .hbm.xml file, like this?
<property name="C_TimeStamp" column="C_TimeStamp" type="timestamp" />
<property name="L_TimeStamp" column="L_TimeStamp" type="timestamp" />
As far as I know Time isn't considered basic type in xml configuration and should be therefore part of the mapping file.
这篇关于引起:org.hibernate.MappingException:无法确定类型:时间戳,列:[org.hibernate.mapping.Column(***)]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!