I have a problem in the structure of an Entity, I am using Hibernate + JPA. The class consists of a user classification, where a primary key will be the user (coming from the Usuario class), and the other is the season (coming from the Temporada class). Below the class structure:
@Entity(name = "CLASSIFICACAO")
@Data
public class Classificacao implements Serializable
{
@Id
@GeneratedValue(generator="SharedPrimaryKeyGenerator")
@GenericGenerator(name="SharedPrimaryKeyGenerator",strategy="foreign",parameters = @Parameter(name="property", value="usuario"))
@Column(unique = true, nullable = false)
private String classificacao;
@Id
@GeneratedValue(generator="SharedPrimaryKeyGenerator")
@GenericGenerator(name="SharedPrimaryKeyGenerator",strategy="foreign",parameters = @Parameter(name="property", value="temporada"))
@Column(unique = true, nullable = false)
private Long codTemporada;
//another fields
@OneToOne
@PrimaryKeyJoinColumn
private Usuario usuario;
@ManyToOne
@PrimaryKeyJoinColumn
private Temporada temporada;
}
The 'classificacao' field receives the user's name from the Usuario foreign key; Before I didn't have the 'codTemporada' field as a primary, and it worked like a charm. 'classificacao' received user and was primary, and the 'temporada' only foreign. But now I need the 'codTemporada' field to be primary as well, making a composite primary key class. But I just received the error: broken column mapping for: usuario.id of: br.com.xxxxx.model.Classificacao.
Any suggestions of what I can do?