当前位置: 代码迷 >> J2SE >> hibernate出错解决办法
  详细解决方案

hibernate出错解决办法

热度:37   发布时间:2016-04-24 13:05:20.0
hibernate出错
log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).
log4j:WARN Please initialize the log4j system properly.
Exception in thread "main" org.hibernate.MappingException: component class not found: com.Ivy.hb.PersonId
at org.hibernate.mapping.Component.getComponentClass(Component.java:101)
at org.hibernate.tuple.PojoComponentTuplizer.buildGetter(PojoComponentTuplizer.java:105)
at org.hibernate.tuple.AbstractComponentTuplizer.<init>(AbstractComponentTuplizer.java:40)
at org.hibernate.tuple.PojoComponentTuplizer.<init>(PojoComponentTuplizer.java:112)
at org.hibernate.tuple.TuplizerLookup.create(TuplizerLookup.java:68)
at org.hibernate.mapping.Component.getType(Component.java:156)
at org.hibernate.mapping.SimpleValue.isValid(SimpleValue.java:252)
at org.hibernate.mapping.RootClass.validate(RootClass.java:189)
at org.hibernate.cfg.Configuration.validate(Configuration.java:839)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1000)
at com.Ivy.hb.OperatePerson.<init>(OperatePerson.java:12)
at com.Ivy.hb.test.main(test.java:7)
Caused by: java.lang.ClassNotFoundException: com.Ivy.hb.PersonId
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at org.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:108)
at org.hibernate.mapping.Component.getComponentClass(Component.java:98)
... 11 more
出错信息如上.
不知道错误在哪里,下面是我的xml文档:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- 
  Mapping file autogenerated by MyEclipse Persistence Tools
-->
<hibernate-mapping>
  <class name="com.Ivy.hb.Person" table="person" catalog="mysql">
  <composite-id name="id" class="com.Ivy.hb.PersonId">
  <key-property name="id" type="java.lang.String">
  <column name="id" length="10" />
  </key-property>
  <key-property name="name" type="java.lang.String">
  <column name="name" length="10" />
  </key-property>
  <key-property name="age" type="java.lang.String">
  <column name="age" length="10" />
  </key-property>
  </composite-id>
  </class>
</hibernate-mapping>


------解决方案--------------------
提示的很明确了啊,缺少类com.Ivy.hb.PersonId 


你肯定是使用的是联合主键,那么相应的就要生成一个针对联合主键的类
------解决方案--------------------
com.Ivy.hb.PersonId类没有找到
  相关解决方案