简体   繁体   English

无法确定类型:TIMESTAMP,表:BATCH_JOB_CONFIG_DTLS,列:[org.hibernate.mapping.Column(ADD_USER_DTM)]

[英]Could not determine type for: TIMESTAMP, at table: BATCH_JOB_CONFIG_DTLS, for columns: [org.hibernate.mapping.Column(ADD_USER_DTM)]

Exception in thread "main" org.hibernate.MappingException: Could not determine type for: TIMESTAMP, at table: BATCH_JOB_CONFIG_DTLS, for columns: [org.hibernate.mapping.Column(ADD_USER_DTM)]
    at org.hibernate.mapping.SimpleValue.getType(SimpleValue.java:486)
    at org.hibernate.mapping.SimpleValue.isValid(SimpleValue.java:453)
    at org.hibernate.mapping.Property.isValid(Property.java:226)
    at org.hibernate.mapping.PersistentClass.validate(PersistentClass.java:624)
    at org.hibernate.mapping.RootClass.validate(RootClass.java:267)
    at org.hibernate.boot.internal.MetadataImpl.validate(MetadataImpl.java:347)
    at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:466)
    at com.hms.api.batch.job.config.StartBatchJobConfigApplication.createSession(StartBatchJobConfigApplication.java:71)
    at com.hms.api.batch.job.config.StartBatchJobConfigApplication.main(StartBatchJobConfigApplication.java:38)

The following are my codes.以下是我的代码。 calling createSession() method in Main.在 Main 中调用 createSession() 方法。 I have two Entity classes.我有两个实体类。

Database connection is provided in my hibernate.cfg.xml我的 hibernate.cfg.xml 中提供了数据库连接

private static void createSession() {

        StandardServiceRegistry ssr = new StandardServiceRegistryBuilder().configure("hibernate.cfg.xml").build();
        Metadata meta = new MetadataSources(ssr).getMetadataBuilder().build();

        SessionFactory factory = meta.getSessionFactoryBuilder().build();
        Session session = factory.openSession();
        Transaction t = session.beginTransaction();

        SessionFactory fact = meta.getSessionFactoryBuilder().build();
        Session ss = factory.openSession();
        Transaction tt = session.beginTransaction();

        BatchJobConfig config = new BatchJobConfig();

        BatchJobConfigDetails details = new BatchJobConfigDetails();

        Timestamp timestamp = new Timestamp(System.currentTimeMillis());
        System.out.println("timestamp  ->  "+timestamp);

        BatchJobConfigDetails batchJobConfigDtl = new BatchJobConfigDetails(300, 3, "JAVA", date, "JAVA", date, "N",
                "Some Key", "Some value", "FT", "KEY DESCRIPTION", "Y");
        try {
            config.setBatchJobConfigDtl(batchJobConfigDtl);
            config.setAddUserCd("gdfdgdfgdgd");
            config.setBatchJobConfigId(505);
            config.setActiveInd("YYYY");
            config.setAddUserDtm(timestamp);
            config.setDeleteInd("N");
            config.setEndDtm(timestamp);
            config.setJobDesc("DESCRIPTION");
            config.setJobNm("JOB NAME");
            config.setJobType("Job Type");
            config.setLastUpdtDtm(timestamp);
            config.setLastUpdtUserCd("someone");
            config.setStatus("COMPLETED");
            config.setStartDtm(timestamp);
            ss.save(config);
            tt.commit();
            System.out.println("config session saved");

        } catch (HibernateException exception) {
            System.out.println("Problem creating session factory!!!!!!!!!!");
            exception.printStackTrace();
        } finally {
            fact.close();
            ss.close();
        }

        try {
            details.setAddUserCd("fffffffffffffffffffff");
            details.setAddUserDtm(timestamp);           
            details.setBusinessUpdtInd("dssssssss");
            details.setDeleteInd("NNNNNNNNN");
            details.setKeyDataType("ggggggggggggg");
            details.setKeyDesc("Description.......");
            details.setKeyNm("some key name");
            details.setKeyVal("someval");
            details.setLastUpdtDtm(timestamp);
            details.setLastUpdtUserCd("last user");
            BatchJobConfig batchJobConfig = new BatchJobConfig(1L, "JAVA", date, "C#", date, "N", "MissingCK",
                    "JOB DESCRIPTION", "FT", date, date, "COMPLETED", "Y");
            List<BatchJobConfig> b = null;
            b.add(batchJobConfig);
            details.setBatchJobConfigs(b);
            session.save(details);
            t.commit();
            System.out.println("details session saved");

        } catch (HibernateException exception) {
            System.out.println("Problem creating session factory....");
            exception.printStackTrace();
        } finally {
            factory.close();
            session.close();
        }

    }

batchJob.hbm.xml批处理作业.hbm.xml

<?xml version = "1.0" encoding = "utf-8"?>
<!DOCTYPE hibernate-mapping PUBLIC 
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">

<hibernate-mapping>
    <class name="BatchJobConfig" table="BATCH_JOB_CONFIG">

        <meta attribute="class-description">
            This class contains the BATCH_JOB_CONFIG.
        </meta>

        <id name="batchJobConfigId" type="int" column="BATCH_JOB_CONFIG_ID">
            <generator class="native" />
        </id>

        <property name="addUserCd" column="ADD_USER_CD" type="string" />
        <property name="addUserDtm" column="ADD_USER_DTM" type="TIMESTAMP" />
        <property name="lastUpdtUserCd" column="LAST_UPDT_USER_CD"
            type="string" />
        <property name="lastUpdtDtm" column="LAST_UPDT_DTM" type="TIMESTAMP" />
        <property name="deleteInd" column="DELETE_IND" type="string" />
        <property name="jobNm" column="JOB_NM" type="string" />
        <property name="jobDesc" column="JOB_DESC" type="string" />
        <property name="jobType" column="JOB_TYPE" type="string" />
        <property name="startDtm" column="START_DTM" type="TIMESTAMP" />
        <property name="status" column="STATUS" type="string" />
        <property name="endDtm" column="END_DTM" type="TIMESTAMP" />
        <property name="activeInd" column="ACTIVE_IND" type="string" />

        <many-to-one name="BatchJobConfigDetails" column="BATCH_JOB_CONFIG_ID"
            class="BatchJobConfigDetails" not-null="true" />

    </class>

    <class name="BatchJobConfigDetails" table="BATCH_JOB_CONFIG_DTLS">

        <meta attribute="class-description">
            This class contains the BATCH_JOB_CONFIG_DETAILS.
        </meta>

        <id name="batchJobConfigDtlsId" type="int" column="BATCH_JOB_CONFIG_DTLS_ID">
            <generator class="native" />
        </id>

        <property name="batchJobConfigId" column="BATCH_JOB_CONFIG_ID"
            type="int" />
        <property name="addUserCd" column="ADD_USER_CD" type="string" />
        <property name="addUserDtm" column="ADD_USER_DTM" type="TIMESTAMP" />
        <property name="businessUpdtInd" column="BUSINESS_UPDT_IND"
            type="int" />
        <property name="deleteInd" column="DELETE_IND" type="string" />
        <property name="keyDataType" column="KEY_DATA_TYPE" type="string" />
        <property name="keyDesc" column="KEY_DESC" type="string" />
        <property name="keyNm" column="KEY_NM" type="string" />
        <property name="keyVal" column="KEY_VAL" type="string" />
        <property name="lastUpdtDtm" column="LAST_UPDT_DTM" type="TIMESTAMP" />
        <property name="lastUpdtUserCd" column="LAST_UPDT_USER_CD" type="string" />

    </class>

</hibernate-mapping>

And created two of this tables in DB2 Database.并在 DB2 数据库中创建了两个这样的表。 在此处输入图片说明 在此处输入图片说明

My project is spring-boot REST API GET all, GET 1 and PUT operations.我的项目是 spring-boot REST API GET all、GET 1 和 PUT 操作。 Please take a look and let me know where I'm making mistake.请看一看,让我知道我哪里出错了。 Thank you in advance!!!!先感谢您!!!!

Put all small letters "timestamp" instead of capital ones in your hbm.xml file.将所有小写字母“时间戳”而不是大写字母放在 hbm.xml 文件中。 Something like:就像是:

<property name="addUserDtm" column="ADD_USER_DTM" type="timestamp" />

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 引起:org.hibernate.MappingException:无法确定类型:时间戳,列:[org.hibernate.mapping.Column(***)] - Caused by: org.hibernate.MappingException: Could not determine type for: Timestamp, for columns: [org.hibernate.mapping.Column(***)] org.hibernate.MappingException:无法确定类型:java.util.List,在表:user处,用于列:[org.hibernate.mapping.Column(events)] - org.hibernate.MappingException: Could not determine type for: java.util.List, at table: user, for columns: [org.hibernate.mapping.Column(events)] org.hibernate.MappingException:无法确定以下类型:表:对于列:[org.hibernate.mapping.Column(plant) - org.hibernate.MappingException: Could not determine type for: at table: for columns: [org.hibernate.mapping.Column(plant) org.hibernate.MappingException:无法确定类型:在表中:列:[org.hibernate.mapping.Column(卖家)] - org.hibernate.MappingException: Could not determine type for: at table: for columns: [org.hibernate.mapping.Column(seller)] 无法确定以下表的类型:org.json.JSONObject,在表:ordersinfo中,用于列:[org.hibernate.mapping.Column(items)] - Could not determine type for: org.json.JSONObject, at table: ordersinfo, for columns: [org.hibernate.mapping.Column(items)] 无法确定以下类型的字符串:字符串,在表:STUDENT,对于列:[org.hibernate.mapping.Column(SNAME)] - Could not determine type for: String, at table: STUDENT, for columns: [org.hibernate.mapping.Column(SNAME)] 无法确定类型 <DataType> 在表:TableX中,用于org.hibernate.mapping.Column(userPrefs)列 - could not determine type for <DataType> at table: TableX, for columns org.hibernate.mapping.Column(userPrefs) org.hibernate.MappingException:无法确定类型:java.util.Set,在表:Company中,用于列:[org.hibernate.mapping.Column(users)] - org.hibernate.MappingException: Could not determine type for: java.util.Set, at table: Company, for columns: [org.hibernate.mapping.Column(users)] org.hibernate.MappingException:无法确定类型:java.util.List,在表:大学,列:[org.hibernate.mapping.Column(students)] - org.hibernate.MappingException: Could not determine type for: java.util.List, at table: College, for columns: [org.hibernate.mapping.Column(students)] 无法确定类型:java.util.List,在表:file_post,列:[org.hibernate.mapping.Column(file)] - Could not determine type for: java.util.List, at table: file_post, for columns: [org.hibernate.mapping.Column(file)]
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM