I'd like to access the value of "accept-language" in header from model so i can determine which column should i pick.
so for now i have this in my model
@Entity
@Table(name = "categories")
public class Category {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
@Column(name = "title_en")
private String title;
@Column(name = "description_en")
private String description;
private String icon;
}
so i need to change the name of column according to the header language i received, for example if i received (fr) i want to receive the value of column name_fr
@Column(name = "title_fr")
Any help is appreciated. Thanks
I would consider your DB design
I would have a CategoriesInLanguage table with three columns
@Entity
@Table(name = "CategoriesInLanguage")
public class CategoryInLanguage {
private Integer idCategory;
@Column(name = "title")
private String title;
@Column(name = "description")
private String description;
@Column(name = language")
private String = language
}
@Entity
@Table(name = "categories")
public class Category {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
@OneToMany
@JoinColumn(name="idCategory")
public List<CategoryInLanguage> getLanguages() {
return languages;
}
}
something like this
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.