I have a one to many relationship between two of my entites, Airport
and AirportTranslation
:
public class Airport {
@Id
@Column(name = "id")
private Long id;
@OneToMany(mappedBy="airport", fetch = FetchType.LAZY)
private List<AirportTranslation> translations;
}
And:
public class AirportTranslation implements Serializable {
@Id
@Column(name = "id", updatable = false)
private Long id;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "airport_id")
private Airport airport;
@Column(name = "lang")
private String lang;
@Column(name = "name")
private String name;
}
Now I want to get all translations of an airport based on the current language of the system, using the normal syntax: airport.getTranslations()
.
Due to the fact that the current language is dynamic, I can not use hibernate @Where
.
I think using Hibernate @Filter
could be the best option, but I can't find any clean, working sample of that for spring boot applications.