java - 为什么 JPA 需要域对象的无参数构造函数?

标签 java jpa persistence

为什么 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/

相关文章:

java - JPA更新查询问题

java - 将 TIMESTAMPDIFF 与 JPA 条件查询一起使用,并将 hibernate 作为提供者

jakarta-ee - Java EE 6/7 中的持久层设计

java - 非法参数异常 : Can not set UserTransaction field to ServerVMClientUserTransaction

java - 如何计算处理3中两个给定日期之间的天数?

java - 使用 Spring 获取表单数据时出现问题

java - 封闭类与声明类

Javax : Extending named service

java - 外部函数签名中是否需要@PathVariable或@RequestBody?

java - "Type of the parameter must be a class annotated with @Entity"在 Room 中创建 Generic DAO 接口(interface)时