gpt4 book ai didi

java - Hibernate ORM 失败 :org. hibernate.MappingException:无法确定以下类型:

转载 作者:太空宇宙 更新时间:2023-11-04 12:41:17 24 4
gpt4 key购买 nike

我在 hibernate 配置 xml 中遇到问题。

实体:

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>

异常(exception):

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

log4j:WARN 请正确初始化 log4j 系统。初始 SessionFactory 创建失败:org.hibernate.MappingException:无法确定类型:com.ds.supercar.model.places.Location,列:[org.hibernate.mapping.Column(branchlocation)]线程“main”中的异常 java.lang.ExceptionInInitializerError 在 Test.main(Test.java:19)引起原因:org.hibernate.MappingException:无法确定类型:com.ds.supercar.model.places.Location,列:[org.hibernate.mapping.Column(branchlocation)] 在 org.hibernate.mapping.SimpleValue.getType(SimpleValue.java:244) 在 org.hibernate.mapping.SimpleValue.isValid(SimpleValue.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.Configuration.validate(Configuration.java:816) 在 org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1050) 在 Test.main(Test.java:13)

请帮我解决这个异常(exception):

最佳答案

您似乎忘记将映射资源放入 hibernate 配置文件中(在 sessionFactory 标记之间)因此,请使用它并映射您的 hbm。

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

希望这对您有帮助!

关于java - Hibernate ORM 失败 :org. hibernate.MappingException:无法确定以下类型:,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36805554/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com