大家好。我在实体连接方面遇到了大问题。 当我想保存到数据库对象 TournamentCompetitorEntity 时 我明白了
ERROR o.a.c.c.C.\[.\[.\[.\[dispatcherServlet\] -
Servlet.service() for servlet \[dispatcherServlet\]
in context with path \[/ultima\]
threw exception
Request processing failed:
java.lang.IllegalArgumentException:
Unable to locate persister:
Ultima.infrastructure.database.entity.TournamentCompetitorEntity
with root cause
java.lang.IllegalArgumentException:
Unable to locate persister:
Ultima.infrastructure.database.entity.TournamentCompetitorEntity
可能出了什么问题? :)
我确实尝试了一切,但只得到错误:(
我创建了自己的简化实现。正如您所看到的,某种程度上关系的管理方式不同,我认为您可以尝试使用它们,以确保这不仅仅是命名的问题
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Entity
@Table(name = "tournament_competitor")
public class TournamentCompetitorEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
private String competitorEntity;
@OneToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
@JoinColumn(name = "tournament_entity_id", referencedColumnName = "id")
private TournamentEntity tournamentEntity;
@OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
@JoinColumn(name = "competitor_id")
private Set<CompetitorEntity> competitorEntities;
}
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Entity
@Table(name = "competitor")
public class CompetitorEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
private String competitor;
}
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@Table(name = "tournament")
@Entity
public class TournamentEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
private String tournament;
@OneToOne(mappedBy = "tournamentEntity")
private TournamentCompetitorEntity tournamentCompetitorEntity;
}