-1
Good afternoon to you all! I have a doubt in the structure of an Entity, I am using Hibernate+JPA. The class is a user rating, where one primary key will be the user (coming from the User class), and the other is the season (coming from the season class). Below is 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 field classification receives user name from foreign key User; Before I didn’t have the field codTemporated as a primary, and it worked beautifully. Rating received user and was primary, and the season only foreign. But now I need the field season is also primary making a class of primary keys composed. But only pops the error Broken column Mapping for: usuario.id of: br.com.xxxxx.model..
Some light of what I can do ?