Hallo.
Ich habe folgende Entity :
Ich möchte nun über mehrere Spalten ein Unique Constraints erstellen. Wenn ich Spalten verwende - ohne ManyToOne Beziehung - klappt es ohne Probleme. In diesem Beisepil bekomme ich allerdings folgenden Fehler :
Hat jemand einen Tipp für mich.
Ich habe folgende Entity :
Java:
@Entity
@Table(name = "samsCompetition", uniqueConstraints = @UniqueConstraint(columnNames = {"name", "association", "season"}))
public class SamsCompetition implements Competition {
@NonNull
private String name;
@NonNull
@Getter(AccessLevel.NONE)
@ManyToOne
private SamsAssociation association;
@NonNull
@Getter(AccessLevel.NONE)
@ManyToOne
private SamsSeason season;
Ich möchte nun über mehrere Spalten ein Unique Constraints erstellen. Wenn ich Spalten verwende - ohne ManyToOne Beziehung - klappt es ohne Probleme. In diesem Beisepil bekomme ich allerdings folgenden Fehler :
Code:
Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Invocation of init method failed; nested exception is org.hibernate.AnnotationException: Unable to create unique key constraint (name, association, season) on table sams_competition: database column 'association', 'season' not found. Make sure that you use the correct column name which depends on the naming strategy in use (it may not be the same as the property name in the entity, especially for relational types)
Hat jemand einen Tipp für mich.