我正在尝试使用 Hibernate 映射一些现有表。
这很简单:我们有具有多种语言名称的类别。
DDL如下:
create table language (
id integer not null auto_increment,
code varchar(2) not null,
unique (code),
primary key(id)
);
create table category (
id integer not null auto_increment,
parent_id integer default null,
ordr integer not null default 99,
primary key (id)
);
create table category_description (
category_id integer not null,
language_id integer not null,
title varchar(255) not null,
constraint foreign key (category_id) references category(id),
constraint foreign key (country_language_id) references country_language(id),
primary key (category_id, country_language_id)
);
现在我想要一个以语言为键、以描述(表类别_描述)为值的地图,如下所示:
private Map<Language, CategoryDescription> descriptions = new HashMap<Language, CategoryDescription>();
有人可以给我一些关于这方面的指示吗?我已经尝试过“Java Persistence with Hibernate”第 311/312 页上给出的示例,它类似于我的问题,但我只是不明白:(