我无法运行我的项目,因为我收到此错误:
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;
我在这里做错了什么?
答案 0 :(得分:5)
@ OneToMany
映射的目标必须是有效的JPA实体。在您的情况下,类Double
绝对不是实体类,因此是错误消息。如果您只想存储值集合,请考虑使用@ ElementCollection
。
@ElementCollection
private Collection<Double> wegCategoriePrijzen;