0
我有以下表,從here拍攝(如Spring Security的模型的一部分):創建休眠mappings-初學者QN
create table users(
username varchar_ignorecase(50) not null primary key,
password varchar_ignorecase(50) not null,
enabled boolean not null);
create table authorities (
username varchar_ignorecase(50) not null,
authority varchar_ignorecase(50) not null,
constraint fk_authorities_users foreign key(username) references users(username));
create unique index ix_auth_username on authorities (username,authority);
我真正的新hiberanate,我不知道如何映射這些表到休眠xml文件中的映射。如何映射外鍵?如何映射索引?我知道每個表都有一個主鍵,但在這種情況下,權限表不會。那麼這意味着hibernate映射中沒有<id>
列?
這裏是我到目前爲止有:
<class name="com.foo.beans.User" table="users">
<id name="username" column="username"/>
<property name="password" column="password"/>
<property name="enabled" column="enabled"/>
</class>
<class name="com.foo.beans.Authority" table="authorities">
<composite-id name="ix_auth_username">
<key-property name="username" column="username" />
<key-property name="authority" column="authority" />
</composite-id>
</class>
任何想法,我做錯了嗎?謝謝!
你能告訴你的bean結構? – RAS