简体   繁体   English

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

[英]Hibernate ORM Failed:org.hibernate.MappingException: Could not determine type for:

I am having a problem in hibernate config xml. 我在hibernate config xml中遇到问题。

Entity: 实体:

package com.ds.supercar.model.places;

public class Location { 公共课位置{

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 file: 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>

Exception: 例外:

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

log4j:WARN Please initialize the log4j system properly. log4j:WARN请正确初始化log4j系统。 Initial SessionFactory creation Failed:org.hibernate.MappingException: Could not determine type for: com.ds.supercar.model.places.Location, for columns: [org.hibernate.mapping.Column(branchlocation)] Exception in thread "main" java.lang.ExceptionInInitializerError at Test.main(Test.java:19) Caused by: org.hibernate.MappingException: Could not determine type for: com.ds.supercar.model.places.Location, for columns: [org.hibernate.mapping.Column(branchlocation)] at org.hibernate.mapping.SimpleValue.getType(SimpleValue.java:244) at org.hibernate.mapping.SimpleValue.isValid(SimpleValue.java:231) at org.hibernate.mapping.Property.isValid(Property.java:174) at org.hibernate.mapping.PersistentClass.validate(PersistentClass.java:308) at org.hibernate.mapping.RootClass.validate(RootClass.java:186) at org.hibernate.cfg.Configuration.validate(Configuration.java:816) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1050) at Test.main(Test.java:13) 初始SessionFactory创建失败:org.hibernate.MappingException:无法确定类型:com.ds.supercar.model.places.Location,对于列:[org.hibernate.mapping.Column(branchlocation)]线程“main”中的异常Test.main中的java.lang.ExceptionInInitializerError(Test.java:19)引起:org.hibernate.MappingException:无法确定类型:com.ds.supercar.model.places.Location,对于列:[org.hibernate位于org.hibernate.Propping.Property的org.hibernate.mapping.SimpleValue.isValid(SimpleValue.java:231)org.hibernate.mapping.SimpleValue.getType(SimpleValue.java:244)的.mapping.Column(branchlocation)]位于org.hibernate.cfg的org.hibernate.mapping.RootClass.validate(RootClass.java:186)org.hibernate.mapping.PersistentClass.validate(PersistentClass.java:308)的.isValid(Property.java:174)。 Test.main上的org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1050)中的Configuration.validate(Configuration.java:816)(Test.java:13)

Please help me with this exception: 请帮我解决这个例外情况:

it seems you forgot to put mapping resource in your hibernate config file( between sessionFactory tags ) so use this and map your hbm's. 看来你忘了将映射资源放在你的hibernate配置文件中( 在sessionFactory标签之间 ),所以使用它并映射你的hbm。

<mapping resource="com.ds.supercar.model.places.Location.hbm.xml" />

hope this helps you! 希望这对你有所帮助!

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM