当前位置: 首页 > 知识库问答 >
问题:

Hibernate ORM失败:org.Hibernate.MappingException:无法确定类型:

何哲
2023-03-14
package com.ds.supercar.model.places;
private int locationid;
private String street;
private String city;
private String state;
private String pin;

public Location() {
    // TODO Auto-generated constructor stub
}

public Location(int locationid, String street, String city, String state, String pin) {
    super();
    this.locationid = locationid;
    this.street = street;
    this.city = city;
    this.state = state;
    this.pin = pin;
}

public int getLocationid() {
    return locationid;
}

public void setLocationid(int locationid) {
    this.locationid = locationid;
}

public String getStreet() {
    return street;
}

public void setStreet(String street) {
    this.street = street;
}

public String getCity() {
    return city;
}

public void setCity(String city) {
    this.city = city;
}

public String getState() {
    return state;
}

public void setState(String state) {
    this.state = state;
}

public String getPin() {
    return pin;
}

public void setPin(String pin) {
    this.pin = pin;
}

hbm xml文件

<hibernate-mapping>
<class name="com.ds.supercar.model.places.Location" table="supercarlocation" schema="supercar">
    <id name="locationid" column="locationid">
        <generator class="increment"/>
    </id>
    <property name="street"/>
    <property name="city"/>
    <property name="state"/>
    <property name="pin"/>
    </class>

例外情况:

log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).

log4j:警告请正确初始化log4j系统。初始SessionFactory创建失败:org.hibernate.mappingException:无法确定:com.ds.supercar.model.places.location的类型,对于列:[org.hibernate.mapping.simplevalue.isvalid(simplevalue.isvalid),在test.main(test.java:19)线程“main”java.lang.exceptioninInitializerError由:Java:231)在org.hibernate.mapping.property.isvalid(property.java:174)在org.hibernate.mapping.persistentclass.validate(persistentclass.java:308)在org.hibernate.mapping.rootclass.validate(rootclass.java:186)在org.hibernate.cfg.comfiguration.validate(configuration.java:816)在org.hibernate.cfg.comfiguration.buildsessionFactory(

请帮我处理这个例外:

共有1个答案

韦鸣
2023-03-14

您似乎忘记在hibernate配置文件中(在sessionFactory标记之间)放置映射资源,所以使用它并映射您的HBM。

希望这对你有帮助!

 类似资料: