`

org.hibernate.MappingException: Association references unmapped class: com.lj.zh

阅读更多
Caused by: org.hibernate.MappingException: Association references unmapped class: com.lj.zhang.Order
at org.hibernate.cfg.HbmBinder.bindCollectionSecondPass(HbmBinder.java:2521)
at org.hibernate.cfg.HbmBinder$CollectionSecondPass.secondPass(HbmBinder.java:2807)
at org.hibernate.cfg.CollectionSecondPass.doSecondPass(CollectionSecondPass.java:69)
at org.hibernate.cfg.Configuration.originalSecondPassCompile(Configuration.java:1611)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1369)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1756)
at util.HibernateUtil.buildSessionFactory(HibernateUtil.java:19)
at util.HibernateUtil.<clinit>(HibernateUtil.java:13)
... 1 more



这个错误出现在
/**
	 * Called for all collections
	 */
	public static void bindCollectionSecondPass(Element node, Collection collection,
			java.util.Map persistentClasses, Mappings mappings, java.util.Map inheritedMetas)
			throws MappingException {

		if ( collection.isOneToMany() ) {
			OneToMany oneToMany = (OneToMany) collection.getElement();
			String assocClass = oneToMany.getReferencedEntityName();
			PersistentClass persistentClass = (PersistentClass) persistentClasses.get( assocClass );
			if ( persistentClass == null ) {
				throw new MappingException( "Association references unmapped class: " + assocClass );
			}
			oneToMany.setAssociatedClass( persistentClass );
			collection.setCollectionTable( persistentClass.getTable() );

			if ( LOG.isDebugEnabled() ) {
				LOG.debugf( "Mapping collection: %s -> %s", collection.getRole(), collection.getCollectionTable().getName() );
			}
		}


原因是我在User.hbm.xml中配置了One-to-many  , class是Order.

可是Order这个对象的hbm.xml我并没有在hibernate.cfg.xml中配置。
也就是缺少了<mapping resource="Order.hbm.xml"/>
导致出错。


看来Hibernate会在启动时对这些进行很仔细的检查,
怪不得启动这么慢。
分享到:
评论

相关推荐

    hibernate错误解决方案

    nested exception is org.hibernate.MappingException: Repeated column in mapping for entity: com.xindeco.myregister.pojo.MyRegisterInfo column: password (should be mapped with insert="false" update=...

    Spring3.1 集成 JBPM4.4

    NULL 博文链接:https://guoyinjian.iteye.com/blog/1259538

    Hibernate映射导致的几个异常

    标题与描述概述的知识点主要集中在Hibernate映射过程中可能遇到的各种异常情况,这涉及到数据库与对象模型之间的映射问题,以及Hibernate框架在处理这些映射时可能产生的错误。下面将对这些异常进行详细的解释和分析...

    hibernate常见异常

    本文将介绍 Hibernate 中的一些常见异常,包括 net.sf.hibernate.MappingException、net.sf.hibernate.PropertyNotFoundException、org.hibernate.id.IdentifierGenerationException 以及 a different object with ...

    hudson构建错误及解决方法

    Hudson持续集成工具可以集成Maven工具,并支持其项目的自动化构件,我们可以通过对其配置达到以Maven的形式将构件项目自动化管理起来的目的。

    hibernate常见问题及处理.doc

    4. `org.hibernate.id.IdentifierGenerationException: ids for this class must be manually assigned before calling save():` 此异常意味着在尝试保存对象前,对象的主键没有被正确设置。通常,这是由于在映射...

    Hibernate配置常见错误

    错误表现:在初始化SessionFactory时,可能出现“org.hibernate.HibernateException: Could not instantiate dialect class”等异常,这通常是因为Hibernate配置文件中的dialect设置不正确或对应的JDBC驱动未引入。...

    JPA 开发中遇到的错误

    org.hibernate.MappingException: Unable to find column with logical name 这表示Hibernate在构建映射时未能找到与实体属性相对应的数据库列。确保实体类中的属性名称与数据库表中的列名相匹配,或者使用`@...

    org.dozer JAR 包(实现java bean mapper)

    dozer是一款优秀的java bean映射开源框架,完成深度转换Bean&lt;-&gt;Bean的Mapper实现

    orika-sample:使用“ ma.glasnost.orika”的样本

    "orika-sample:使用“ma.glasnost.orika”的样本"是一个关于Java对象映射库Orika的实践项目。Orika是一个高性能、易用的对象映射框架,它简化了Java对象到Java对象之间的数据转换过程。这个项目提供了一系列示例,...

    hibernate常见错误解决方案

    **HibernateException: JDBC Driver class not found: org.gjt.mm.mysql.Driver** **异常描述:** 此异常表明Hibernate无法找到指定的JDBC驱动类。 **解决方法:** - 确保JDBC驱动已添加到项目依赖中。 - 检查...

    hibernate配置properties

    jdbcPros.setProperty("hibernate.connection.driver_class", "org.gjt.mm.mysql.Driver"); jdbcPros.setProperty("hibernate.connection.url", "jdbc:mysql://localhost:3306/your_db"); jdbcPros.setProperty(...

    EmbeddableTypes

    ( org.hibernate.MappingException: Repeated column in mapping for entity:YOUR_ENTITY ),因为表databsae不能具有重复的列名。 JPA定义了@AttributeOverride批注来处理此senario。 @AttributeOverrides({ @...

    最经典的hibernate教程_从入门到精通3(hbiernate学习)

    首先,让我们解决异常`org.hibernate.MappingException: Unknown entity: com.aptech.jb.entity.TblUser`。这个异常通常是因为Hibernate没有找到指定的实体映射文件。解决方法是在`Hibernate.cfg.xml`配置文件中添加...

    hibernate教程从入门到精通第篇共四篇PPT学习教案.pptx

    在使用Hibernate时,可能会遇到`org.hibernate.MappingException: Unknown entity`这样的异常,这通常是因为在配置文件(如Hibernate.cfg.xml)中未指定实体的映射文件。例如,如果实体类为`...

    eclipse反向差件

    - **异常示例**:`org.hibernate.MappingException: Could not configure overrides from file`。 - **解决方法**:这通常是由于生成的`hibernate.reveng.xml`文件格式不正确导致的。解决方法是修改该文件的头部...

    hibernate ppt

    首先,出现 `org.hibernate.MappingException: Unknown entity` 异常通常是因为 Hibernate 没有找到指定的实体映射文件。在本例中,错误提示说没有在 Hibernate.cfg.xml 文件中添加 `&lt;mapping&gt;` 元素来指明 `...

    JSP 开发SSH整合异常解决办法

    而nested exception "org.hibernate.MappingException: Could not get constructor for org.hibernate.persister.entity.SingleTableEntityPersister"则直接指出了问题的根源,在于Hibernate无法找到或获取到用于...

Global site tag (gtag.js) - Google Analytics