Caused by:org.hibernate.DuplicateMappingException:Duplicate class/entity/ mapping

1、错误描述

java.lang.ExceptionInInitializerError

Caused by:org.hibernate.InvalidMappingException:Could not parse mapping document from resource com/you/model/Monkey.hbm.xml

Caused by:org.hibernate.DuplicateMappingException:Duplicate class/entity/ mapping com.you.model.Monkey

2、错误原因

Configuration config = new Configuration();

config.addClass(Monkey.class);

ServiceRegistry serviceRegistry = new ServiceRegistry().applySettings(config.getProperties().buildServiceRegistry();

sessionFactory = config.buildSessionFactory(serviceRegistry);

3、解决办法

由于配置文件已经添加到Monkey.class,而config.addClass(Monkey.class);又重复添加,故需要将此注释掉

Configuration config = new Configuration();

//config.addClass(Monkey.class);

ServiceRegistry serviceRegistry = new ServiceRegistry().applySettings(config.getProperties().buildServiceRegistry();

sessionFactory = config.buildSessionFactory(serviceRegistry);

时间: 2024-08-02 11:03:32

Caused by:org.hibernate.DuplicateMappingException:Duplicate class/entity/ mapping的相关文章

Caused by: org.hibernate.DuplicateMappingException: Duplicate class/entity mapping com.you.flex.mode

1.错误描述 2015-09-21 00:02:09 [main] WARN org.springframework.context.support.GenericApplicationContext - Exception encountered during context initialization - cancelling refresh attempt org.springframework.beans.factory.BeanCreationException: Error cre

Atitit.解决org.hibernate.DuplicateMappingException: Duplicate class/entity mapping

Atitit.解决org.hibernate.DuplicateMappingException: Duplicate class/entity mapping 1. 排除流程::: @Deprecated public class HibernateSessionFactory { static { try { configuration.configure(propertyFile); sessionFactory = configuration.buildSessionFactory();

Caused by org hibernate DuplicateMappingException Duplicat

1.错误描述 2015-09-21 00:02:09 [main] WARN org.springframework.context.support.GenericApplicationContext - Exception encountered during context initialization - cancelling refresh attempt org.springframework.beans.factory.BeanCreationException: Error cre

hibernate3 Duplicate class/entity mapping(异常)

hibernate3 Duplicate class/entity mapping(异常) 代码:      Configuration config = new Configuration().addClass(User.class).buildSessionFactory(); 解决方法:去掉红色的代码.原因: sessionFactory = config.configure().buildSessionFactory(),已经读取了一次配置, (它会与hibernate.cfg.xml里

Caused by: org.hibernate.hql.internal.ast.QuerySyntaxException: table is not Mapped问题解决

引言: 在基于SpringData/JPA来快速开发若干功能过程中,碰到了table is not Mapped问题,经过一番辛苦的调试测试之后,才发现了一个@Entity的属性name的妙用. 1. 问题的提出 场景描述: 在开发中,做几个功能类似的模块,但代码需要独立,方便后续的独立部署.故出现了很多包路径不同,但是类的名称类似的类.在Model中定义了很多名称相同的实体类,都是以@Entity来定义的. @Entity @Table(name="table1") public c

org.hibernate.MappingException: Repeated column in mapping for entity: com.boot.entity.RepEntity column: rep_batch (should be mapped with insert="false" update="false")

Caused by: org.hibernate.MappingException: Repeated column in mapping for entity: com.boot.entity.RepEntity column: rep_batch (should be mapped with insert="false" update="false") at org.hibernate.mapping.PersistentClass.checkColumnDup

org.hibernate.InvalidMappingException: Could not parse mapping document from resource com/domain/book.hbm.xml 联网跑一跑

org.hibernate.InvalidMappingException: Could not parse mapping document from resource com/domain/book.hbm.xml at org.hibernate.cfg.Configuration.addResource(Configuration.java:586) at org.hibernate.cfg.Configuration.addClass(Configuration.java:633) a

Caused by: org.hibernate.id.IdentifierGenerationException: ids for this class must be manually assigned before calling save(): com.qingmu.seller.entity.OrderMaster

org.springframework.orm.jpa.JpaSystemException: ids for this class must be manually assigned before calling save(): com.qingmu.seller.entity.OrderMaster; nested exception is org.hibernate.id.IdentifierGenerationException: ids for this class must be m

Caused by: org.hibernate.tool.schema.spi.SchemaManagementException: Schema-validation: wrong column type encountered in column [others] in table [auth_user]; found [varchar (Types#VARCHAR)], but expec

Caused by: org.hibernate.tool.schema.spi.SchemaManagementException: Schema-validation: wrong column type encountered in column [others] in table [auth_user]; found [varchar (Types#VARCHAR)], but expecting [integer (Types#INTEGER)] 这个错误是由于使用springdata