我有一个包含列的表国家/地区:
id, en, de, fr, ru, lt
id - primary key
en,de,... - localization
我想写实体,如:
@Entity
@Table(name = "countries")
public class EntityCountry {
@Id
@Column(name = "id")
@GeneratedValue
private int id;
@Localization
private String name;
让实体像:
Session session = HibernateUtils.getSessionFactory().openSession();
session.beginTransaction();
EntityCountry e = (EntityCountry) session.createQuery("from EntityCountry where id = 1").setLocalization("en").uniqueResult();
session.getTransaction().commit();
session.close();
请帮助我如何做到这一点?