为什么 JPA 需要域对象的无参数构造函数?
我正在使用 eclipselink 并且在部署过程中遇到了这个异常。
Exception [EclipseLink-63] (Eclipse Persistence Services-1.1.0.r3639-SNAPSHOT):
org.eclipse.persistence.exceptions.DescriptorException
Exception Description: The instance creation method
[com.me.model.UserVO.<Default Constructor>], with no parameters,
does not exist, or is not accessible.
Internal Exception: java.lang.NoSuchMethodException:
com.me.model.UserVO.<init>()
Descriptor: RelationalDescriptor(com.me.model.UserVO -->
[DatabaseTable(user)])
最佳答案
因为经常发生 JPA 提供者必须动态实例化您的域对象的情况。它不能这样做,除非有一个无参数构造函数——它无法猜测参数应该是什么。
关于java - 为什么 JPA 需要域对象的无参数构造函数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2808747/