Spring + toplink-essentials(JPA) is not a known entity type 问题解决

本文介绍了解决Spring框架结合TopLink Essentials在使用Java持久化API (JPA)时遇到的“未知实体类型”错误的方法。主要分为三种解决途径:调整Spring配置排除特定配置项、使用静态编织或禁用装载期编织、以及通过指定类加载器实现。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Spring + toplink-essentials(JPA) is not a known entity type 问题解决:

本文链接:http://blog.youkuaiyun.com/myloon/archive/2009/11/08/4784846.aspx


第一种方法:
不能有loadTimeWeaver配置,包括<bean id="loadTimeWeaver">或<context:load-time-weaver/>或 <property

name="loadTimeWeaver" />都不能有。
然后在persistence.xml文件<properties>中加入:
<property name="toplink.weaving" value="static" />
或者
<property name="toplink.weaving" value="false" />
即可,也可以在spring配置加入此属性,此种方法在JavaSE环境中测试通过,JavaEE环境有待测试。
第二种方法:
加入:
<context:load-time-weaver/>
<context:load-time-weaver weaver-class="org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver" />
或者
<bean id="loadTimeWeaver" class="org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver" />
需要spring-agent.jar,然后再JVM 运行参数中加入:-javaagent:F:/spring-framework-2.5.5/dist/weaving/spring-agent.jar 即可。
此种方法在JavaSE环境中测试通过,JavaEE环境有待测试。
在容器中,需要指定类载入:
org.springframework.instrument.classloading.tomcat.TomcatInstrumentableClassLoader
org.springframework.instrument.classloading.glassfish.GlassFishLoadTimeWeaver
org.springframework.instrument.classloading.weblogic.WebLogicLoadTimeWeaver
第三种方法:

同第二种启动VM参数加入-javaagent:toplink-essentials-agent.jar,该方法没有测试。
参考:
http://blog.springsource.com/2006/05/30/getting-started-with-jpa-in-spring-20/
http://www.oracle.com/technology/products/ias/toplink/jpa/how-to-index.html
http://www.oracle.com/technology/products/ias/toplink/JPA/essentials/toplink-jpa-extensions.html#TopLinkCustomizationValidation
http://www.oracle.com/technology/products/ias/toplink/JPA/essentials/toplink-jpa-extensions.html#LazyLoading

本文链接:http://blog.youkuaiyun.com/myloon/archive/2009/11/08/4784846.aspx

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值