facebook

select in hibernate from a table

  1. MyEclipse IDE
  2.  > 
  3. Off Topic
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #312386 Reply

    amir55
    Participant

    hi

    I have a table called course_user in thsi shape

    courseId userId
    2 1
    3 1

    in sql we can do this

    select courseId from course_user where userId = 1 ;

    how ca we do that in hibernate ?

    thanks a lot

    Amir

    #312390 Reply

    amir55,

    Here is the way you can select in Hibernate:

    select courseuser.courseId from course_user courseuser where courseuser.userId = 1 ;

    Do let us know how it works for you.

    #312519 Reply

    amir55
    Participant

    hi dear Shirani

    many thanks

    the code of quering a table is not working
    queryString = “select course.courseId from course_user where course.user.userId = 1” ;

    the error is
    course_user is not mapped

    because the course_user is a table and not a class. Can you kindly enquire one of your hibernate team on how hibernate execute standard sql statements

    many thanks with high appreciations

    Amir

    #312526 Reply

    support-joy
    Member

    Amir,

    Please go through this link.
    http://www.roseindia.net/hibernate/selectclause.shtml

Viewing 4 posts - 1 through 4 (of 4 total)
Reply To: select in hibernate from a table

You must be logged in to post in the forum log in