@IdClass and @GeneratedValue not working in Hibernate

@IdClass and @GeneratedValue works properly in Hibernate. We have a test in the documentation folder that proves it.

The problem in your code comes from this mapping:

@ManyToOne
private Samplings sampling;

The Samples entity will expect a samplings_id FK to reference the Samplings table PK. But the Samplings table has a composite identifier.

Therefore, you need to use @JoinColumns:

@ManyToOne
@JoinColumns({
	@JoinColumn(
		name = "samplings_id",
		referencedColumnName = "id"),
	@JoinColumn(
		name = "samplings_year",
		referencedColumnName = "year")
})
private Samplings sampling;

For more details about mapping composite identifiers, check out the User Guide.