我正在使用EclipseLink(2.5.1,也尝试过2.5.2-M1)构建一个java SE 8(oracle 1.8.0-b129)应用程序,并且有一个实体类,即使被正确注释,也只是被EclipeLink忽略了.在persistence.xml文件中引用.日志显示没有提及类,没有为它生成模式,等等.使用实体给出'抽象模式类型未知'错误.
我想我终于找到了原因,并认为我会分享.显然,EclipseLink不喜欢带有lambda表达式的类.这是一个简单的类来重现问题:
@Entity
public class LambdaEntity {
@Id
private Integer id;
public void theLambda() {
Arrays.asList(1, 2, 3).stream().filter(m -> m == 2);
}
}
Run Code Online (Sandbox Code Playgroud)
lambda表达式甚至不必使用持久属性,它在类中的简单存在就足够了.有谁知道是什么原因引起的?我猜测EclipeLink会对生成的字节码产生阻塞,但我发现很奇怪它会默默地忽略该类.
如果您尝试在与其他实体的关联中使用此实体,EclipseLink将提供错误,指出该实体未在该persistence.xml文件中定义.stacktrace的一部分:
Local Exception Stack:
Exception [EclipseLink-30005] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.PersistenceUnitLoadingException
Exception Description: An exception was thrown while searching for persistence archives with ClassLoader: sun.misc.Launcher$AppClassLoader@3b9a45b3
Internal Exception: javax.persistence.PersistenceException: Exception [EclipseLink-28018] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.EntityManagerSetupException
Exception Description: Predeployment of PersistenceUnit [hcm-test] failed.
Internal Exception: Exception [EclipseLink-7250] (Eclipse Persistence …Run Code Online (Sandbox Code Playgroud)