当前页面: 开发资料首页 → J2SE 专题 → 请教hibernate外键查询的问题
请教hibernate外键查询的问题
摘要: 请教hibernate外键查询的问题
user表
UserId pk
....
user_role表
UserId fk
RoleId
--------------
两个 hbm.xml 该怎么配啊
查询的地方要怎么写啊
看了不少例子,还是不会,哪位好心的给指点一下。
多谢了!
想跟据一个 RoleId 查符合条件的所有 user, 该怎么写啊
user.hbm.xml
-#60;hibernate-mapping package=-#34;xxx.user-#34;-#62;
-#60;class
name=-#34;user-#34;
table=-#34;User-#34;
-#62;
-#60;id
name=-#34;UserId-#34;
type=-#34;string-#34;
column=-#34;UserId-#34;
-#62;
-#60;generator class=-#34;uuid.hex-#34;/-#62;
-#60;/id-#62;
-#60;property
name=-#34;UserName-#34;
column=-#34;UserName-#34;
type=-#34;string-#34;
not-null=-#34;false-#34;
/-#62;
-#60;/class-#62;
-#60;/hibernate-mapping-#62;
user_role.hbm.xml
-#60;hibernate-mapping package=-#34;xxx.UserRole-#34;-#62;
-#60;class
name=-#34;UserRole-#34;
table=-#34;user_role-#34;
-#62;
-#60;meta attribute=-#34;sync-DAO-#34;-#62;true-#60;/meta-#62;
-#60;id
name=-#34;Id-#34;
type=-#34;string-#34;
column=-#34;ID-#34;
-#62;
-#60;generator class=-#34;uuid.hex-#34;/-#62;
-#60;/id-#62;
-#60;property
name=-#34;UserId-#34;
column=-#34;UserId-#34;
type=-#34;string-#34;
not-null=-#34;true-#34;
length=-#34;32-#34;
/-#62;
-#60;property
name=-#34;RoleId-#34;
column=-#34;ROLE_ID-#34;
type=-#34;string-#34;
not-null=-#34;true-#34;
length=-#34;50-#34;
/-#62;
-#60;many-to-one
class=-#34;User-#34;
name=-#34;user-#34;
column=-#34;UserId-#34;
not-null=-#34;true-#34;/-#62;
-#60;/class-#62;
-#60;/hibernate-mapping-#62;
后面怎么写呢?
没人啊~~~
无奈啊~~