在构建带有依赖项的maven项目时,我一直收到以下错误:
Exception Description: The target entity of the relationship attribute
[template] on the class [class pt.ipleiria.dae.entities.Configuration]
cannot be determined. When not using generics, ensure the target entity is
defined on the relationship mapping.我有这两个实体,代码如下:配置:
@ManyToMany(mappedBy="configurations")
private Template template;
private String name;
private ConfigurationState state;
private String version;
private String description;
private List<Module> modules;
private List<Resource> resources;
private List<String> parameters;
private List<String> extensions;
private String contrato;模板(关系的所有者):
@ManyToMany
@JoinTable(name="TEMPLATE_CONFIGURATIONS",
joinColumns=
@JoinColumn(name="ID", referencedColumnName="ID"),
inverseJoinColumns=
@JoinColumn(name="ID", referencedColumnName="ID")
)
private List<Configuration> configurations;我希望有一个多对多的关系,因为一个“模板”包含几个“配置”,而“配置”可以在几个“模板”(配置)中。
发布于 2018-12-23 21:39:19
通常,当您在定义关系的Many端时没有定义Generics,就会出现您定义的异常,如解释的here
尽管在您的情况下,还有一些其他的问题。
由于您已经在Configuration和Template之间应用了@ManyToMany关系,因此应该在Configuration Entity中这样定义。
@ManyToMany(mappedBy="configurations")
private List<Template> templates;如果你要求配置只能在模板上,而一个模板可以有多个配置,你应该使用OneToMany relationship。在配置实体中,您将拥有:
@ManyToOne(mappedBy="configurations")
private Template template;在模板实体中,您将拥有
@OneToMany
private List<Configuration> configurations;希望这能有所帮助!!
https://stackoverflow.com/questions/53903593
复制相似问题