Java 原因:org.hibernate.MappingException:无法确定以下列的类型:Timestamp:[org.hibernate.mapping.Column(***)]

Java 原因:org.hibernate.MappingException:无法确定以下列的类型:Timestamp:[org.hibernate.mapping.Column(***)],java,mysql,oracle,hibernate,mappingexception,Java,Mysql,Oracle,Hibernate,Mappingexception,使用hibernate。。我现在正在学习这项技术。。不确定我错在哪里…请在这方面指导 在尝试将-TIMESTAMP()类型的db中的列映射到Pojo变量时,我看到了上述错误。。。 我尝试将变量类型更改为日期…日历…时间戳。。这里什么都不管用。。。 问题似乎在于列的映射。。。非常感谢您在这方面的任何帮助 我的pojo课程: public class Pojo_**** { ......... private Date C_TimeStamp; private Date L_TimeStamp;

使用hibernate。。我现在正在学习这项技术。。不确定我错在哪里…请在这方面指导

在尝试将-TIMESTAMP()类型的db中的列映射到Pojo变量时,我看到了上述错误。。。 我尝试将变量类型更改为日期…日历…时间戳。。这里什么都不管用。。。 问题似乎在于列的映射。。。非常感谢您在这方面的任何帮助

我的pojo课程:

public class Pojo_****
{ ......... 
private Date C_TimeStamp; 
private Date L_TimeStamp;
}
我的数据库表:

Table_****
    ..........
    C_TimeStamp TIMESTAMP(6)
    L_TimeStamp TIMESTAMP(6)
 Pojo_****.hbm.xml
        ......
        <property name="C_TimeStamp" column="C_TimeStamp" />
        <property name="L_TimeStamp" column="L_TimeStamp" />
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)
我的配置xml:

Table_****
    ..........
    C_TimeStamp TIMESTAMP(6)
    L_TimeStamp TIMESTAMP(6)
 Pojo_****.hbm.xml
        ......
        <property name="C_TimeStamp" column="C_TimeStamp" />
        <property name="L_TimeStamp" column="L_TimeStamp" />
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)
Pojo_****.hbm.xml
......
错误日志:

Table_****
    ..........
    C_TimeStamp TIMESTAMP(6)
    L_TimeStamp TIMESTAMP(6)
 Pojo_****.hbm.xml
        ......
        <property name="C_TimeStamp" column="C_TimeStamp" />
        <property name="L_TimeStamp" column="L_TimeStamp" />
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)
主应用程序的主方法中的
。。。
2016年3月9日下午2:48:14 org.hibernate.cfg.Environment
信息:Hibernate 3.2 cr4
2016年3月9日下午2:48:14 org.hibernate.cfg.Environment
信息:找不到hibernate.properties
2016年3月9日下午2:48:14 org.hibernate.cfg.Environment buildBytecodeProvider
信息:字节码提供程序名称:cglib
2016年3月9日下午2:48:14 org.hibernate.cfg.Environment
信息:使用JDK1.4java.sql.Timestamp处理
2016年3月9日下午2:48:15 org.hibernate.cfg.Configuration
信息:从资源配置:hibernate.cfg.xml
2016年3月9日下午2:48:15 org.hibernate.cfg.Configuration getConfigurationInputStream
信息:配置资源:hibernate.cfg.xml
2016年3月9日下午2:48:15 org.hibernate.cfg.Configuration addResource
信息:从资源中读取映射:Pojo_****.hbm.xml
2016年3月9日下午2:48:15 org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
信息:映射类:Pojo_****->表_****
2016年3月9日下午2:48:15 org.hibernate.cfg.Configuration doConfigure
信息:配置的会话工厂:空
未能创建sessionFactory object.org.hibernate.MappingException:无法确定以下列的类型:Timestamp:[org.hibernate.mapping.Column(L_Timestamp)]
线程“main”java.lang.ExceptionInInitializeError中出现异常
位于tutorialspoint.example.MainApp.main(MainApp.java:29)
原因:org.hibernate.MappingException:无法确定以下列的类型:Timestamp:[org.hibernate.mapping.Column(L_Timestamp)]
位于org.hibernate.mapping.SimpleValue.getType(SimpleValue.java:266)
位于org.hibernate.mapping.SimpleValue.isValid(SimpleValue.java:253)
位于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.Configuration.validate(Configuration.java:1026)
位于org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1211)
位于tutorialspoint.example.MainApp.main(MainApp.java:21)

尝试将日期时间填入变量。我在项目中遇到了同样的问题,并由此得到了解决

  Pojo_Class obj_Pojo = new Pojo();

try {
            //Or Pass any Date Object.
        obj_Pojo.setC_TimeStamp(new SimpleDateFormat("yyyy/MM/dd HH:mm:ss").parse(String.valueOf(new Date().getTime()))); 

    } catch (ParseException e) {
        v_objBorrower.setCreationDate(new Date());
    }

注意:将数据库列更改为
DateTime
。如果没有任何配置问题,这可能会对您有所帮助。

您是否尝试在.hbm.xml文件中添加type=“timestamp”,如下所示

<property name="C_TimeStamp" column="C_TimeStamp" type="timestamp" />
<property name="L_TimeStamp" column="L_TimeStamp" type="timestamp" />


据我所知,时间在xml配置中不被视为基本类型,因此应该是映射文件的一部分

我已经试着用我的主要方法打印这些字段。。。并使用其他类型的变量-string/int。。。以及从pojo类/**hbm.xml文件中。。。但问题仍然存在……代码段1:代码段2:上述两个代码段的用途相同。。有/没有明确提及类型。我试着按照你的建议执行,又犯了同样的错误。。。