![](/img/trans.png)
[英]org.hibernate.MappingException: Could not determine type for:
[英]Hibernate ORM Failed:org.hibernate.MappingException: Could not determine type for:
我在hibernate config 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>
例外:
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”中的异常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)
请帮我解决这个例外情况:
看来你忘了将映射资源放在你的hibernate配置文件中( 在sessionFactory标签之间 ),所以使用它并映射你的hbm。
<mapping resource="com.ds.supercar.model.places.Location.hbm.xml" />
希望这对你有所帮助!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.