开发者

problem in retrieving the rows in case of composite key through hibernate

开发者 https://www.devze.com 2023-01-25 13:39 出处:网络
I have faced this issue many times but couldn\'t find the solution any where. My question is that how can i retrieve a tuple or a row in the database through hibernate call,

I have faced this issue many times but couldn't find the solution any where.

My question is that how can i retrieve a tuple or a row in the database through hibernate call,

For ex开发者_JAVA百科ample in the relation Student_course(sid,sname,cid,cname, duration) here sid and cid are considered as the composite key.

please let me know the solution.

Thanks In Adv, A.Raghavendra


Configure the Mapping file as below,

<hibernate-mapping>
    <class
        name="com.example.StudentCourse"
        table="Student_course">
        <composite-id> 
         <key-many-to-one name="student" class="com.example.Student" column="student_ID"/>    
         <key-many-to-one name="course" class="com.example.Course" column="course_ID"/>     
    </composite-id> 
    ///Other mappings elements

In the java, if you retrive the List of Student course you can get the details.

0

精彩评论

暂无评论...
验证码 换一张
取 消