1

我无法运行我的项目,因为我收到此错误:

Exception Description: Predeployment of PersistenceUnit [RekeningAdministratiePU] failed.
Internal Exception: Exception [EclipseLink-7250] (Eclipse Persistence Services - 2.3.2.v20111125-r10461): org.eclipse.persistence.exceptions.ValidationException
Exception Description: [class domain.Regio] uses a non-entity [class java.lang.Double] as target entity in the relationship attribute [field wegCategoriePrijzen].
javax.persistence.PersistenceException: Exception [EclipseLink-28018] (Eclipse Persistence Services - 2.3.2.v20111125-r10461): org.eclipse.persistence.exceptions.EntityManagerSetupException
Exception Description: Predeployment of PersistenceUnit [RekeningAdministratiePU] failed.
Internal Exception: Exception [EclipseLink-7250] (Eclipse Persistence Services - 2.3.2.v20111125-r10461): org.eclipse.persistence.exceptions.ValidationException
Exception Description: [class domain.Regio] uses a non-entity [class java.lang.Double] as target entity in the relationship attribute [field wegCategoriePrijzen].

我的实体类看起来像这样

@Id
@GeneratedValue(strategy= GenerationType.IDENTITY)
private Long id;
private String naam;
@OneToMany(cascade= { CascadeType.PERSIST,CascadeType.MERGE,CascadeType.REMOVE})
private Collection<Locatie> locaties;
@OneToMany(cascade= { CascadeType.PERSIST,CascadeType.MERGE,CascadeType.REMOVE})
private Collection<Double> autoCategorieMutaties;
@OneToMany(cascade= { CascadeType.PERSIST,CascadeType.MERGE,CascadeType.REMOVE})
private Collection<Double> wegCategoriePrijzen;
private Double binnenrijTarief;

我在这里做错了什么?

4

1 回答 1

5

@OneToMany映射的目标必须是有效的 JPA 实体。在您的情况下,该类Double肯定不是实体类,因此会出现错误消息。如果您只是想存储值的集合,请考虑改用 @ ElementCollection

@ElementCollection
private Collection<Double> wegCategoriePrijzen;
于 2013-04-09T20:24:23.950 回答