【发布时间】:2013-06-20 19:16:25
【问题描述】:
我有一个实体:
@Entity
public class MyEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = Columns.ID)
private Long id;
// getter & setter
}
然后,我创建实体MyEntity my = new MyEntity(); 的实例,并希望使用DAO(使用JPA 的Spring Data)-dao.save(my); 保存它。我遇到了以下异常:
Caused by: Exception [EclipseLink-6023]
(Eclipse Persistence Services - 2.4.0.v20120608-r11652):
org.eclipse.persistence.exceptions.QueryException
Exception Description: The list of fields to insert into the table
[DatabaseTable(my_entity)] is empty.
You must define at least one mapping for this table.
Query: InsertObjectQuery(null)
当我使用默认值向实体添加另一个无用的列时
private int nothing = 6;
异常消失。有什么解决办法吗?
This topic 对我没有帮助。我使用 EclipseLink + MySQL + Spring Data。
【问题讨论】:
标签: java mysql jpa eclipselink spring-data-jpa