entity anger-junit4报IllegalArgumentException: Unknown entity

问题描述

junit4报IllegalArgumentException: Unknown entity

环境:jpa2.0 +hibernate4.0 +spring3.2

代码截图:

报错信息

java.lang.IllegalArgumentException: Unknown entity: com.danaaa.shop.entity.Area
at org.hibernate.ejb.AbstractEntityManagerImpl.find(AbstractEntityManagerImpl.java:793)
at org.hibernate.ejb.AbstractEntityManagerImpl.find(AbstractEntityManagerImpl.java:756)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.springframework.orm.jpa.SharedEntityManagerCreator$SharedEntityManagerInvocationHandler.invoke(SharedEntityManagerCreator.java:257)
at com.sun.proxy.$Proxy31.find(Unknown Source)
at com.danaaa.shop.dao.impl.BaseDaoImpl.find(BaseDaoImpl.java:69)
at com.danaaa.shop.service.impl.BaseServiceImpl.find(BaseServiceImpl.java:53)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:98)
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:262)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:95)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207)
at com.sun.proxy.$Proxy80.find(Unknown Source)
at com.danashop.test.service.SuiteServiceImplTest.testAddSuiteToCart(SuiteServiceImplTest.java:106)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74)
at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:83)
at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:232)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:89)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:71)
at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:175)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: org.hibernate.MappingException: Unknown entity: com.danaaa.shop.entity.Area
at org.hibernate.impl.SessionFactoryImpl.getEntityPersister(SessionFactoryImpl.java:693)
at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:92)
at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:1090)
at org.hibernate.impl.SessionImpl.get(SessionImpl.java:1005)
at org.hibernate.impl.SessionImpl.get(SessionImpl.java:998)
at org.hibernate.ejb.AbstractEntityManagerImpl.find(AbstractEntityManagerImpl.java:781)
... 51 more

时间: 2024-12-25 10:28:13

entity anger-junit4报IllegalArgumentException: Unknown entity的相关文章

java-hibernate5.0.6报错Unknown entity

问题描述 hibernate5.0.6报错Unknown entity 网上这个错误的解决方法很多,我都试过了但是没有一个行的,确认我的配置文件没写错,请问是什么问题?报错 Exception in thread "main" org.hibernate.MappingException: Unknown entity: com.hibernate.Student at org.hibernate.internal.SessionFactoryImpl.getEntityPersist

@OneToOne or @ManyToOne on references an unknown entity:

1使用hibernate和spring MVC 时报错: Xml代码   Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [beans.xml]: Invocation of init method failed; nested exception is 

spring-org.hibernate.MappingException: Unknown entity:

问题描述 org.hibernate.MappingException: Unknown entity: 一直报找不到entity,不知道什么原因 一.以下是我entity,引入的也是import javax.persistence.Entity;而不是hibernate的 import java.io.Serializable; import java.util.Date; import javax.persistence.Column; import javax.persistence.En

Nhibernate Unknown entity class 的解决办法

概述:      当运行 session.Save(tnp);时,出现这个"Unknown entity class: TestCleanSnow.TestNhibernatePerson"这个异常.      映射文件 TestNhibernatePerson.hbm.xml如下:   <?xml version="1.0" encoding="utf-8"?><hibernate-mapping xmlns="ur

进程间通讯-Android开发 AIDL接口文件里使用内部类报错unknown type

问题描述 Android开发 AIDL接口文件里使用内部类报错unknown type 在Android开发时涉及到一个进程间通讯,要传递一个内部类对象到远程服务端.已经把内部类对象用Parcelable序列化了,但是编译总是报错unknown type 外部类.内部类. 1.AIDL能否传递内部类对象到远程端? 2.此问题该怎样解决?

网络-linux下访问百度就会报ping: unknown host www.baidu.com的错误

问题描述 linux下访问百度就会报ping: unknown host www.baidu.com的错误 本地网络配置如下: 求快速回复 解决方案 是在本机安装还是在虚拟机?如果是在本机,看看网卡驱动是否安装了.虚拟机的话,ping 127.0.0.1 能ping的话,就是dns设置有问题了,可以Google一下 centos网卡设置,之前我弄过,不过具体没记住,网上有很多.感觉你的是本机,跟我之前的很类似,有网卡,但是上不了网,这是因为网卡驱动没安装的原因. 可以去官网下载一个驱动包for

idea 运行报错Unknown system variable &amp;amp;#39;language&amp;amp;#39;怎么解决

问题描述 idea 运行报错Unknown system variable 'language'怎么解决 idea 运行报错Unknown system variable 'language'怎么解决 解决方案 Unknown system variable 'storage_engine'解决办法

entity framework-mvc5 Controller with views, using Entity Framework

问题描述 mvc5 Controller with views, using Entity Framework 解决方案 [ASP.NET MVC5 - 03] Entity FrameWork and ModelHTML5, jQuery Mobile and ASP.NET MVC 4 – Using the ViewModel between the model and controllerUsing StructureMap with the ASP.NET MVC framework

Hibernate 关于配置Mapping不成功 Unknow Entity

Hibernate 5.xx加载hibernate.cfg.xml时<mapping resource="xxx.hbm.xml" />不生效,必须使用config.addClass()才行,否则就报org.hibernate.MappingException: Unknown entity异常 把Hibernate换回到4.x就生效了. 因为获取Seeeion Factory的方法发生了变化 应使用 StandardServiceRegistry serviceRegis