my table is Student sid fname lname subject phno --- ----- ----- -------- ----- 1 vvk v math 4444 1 vvk v read 4444 2 hari h math 5555 2 hari h read 5555 3 kalyan k math 6666 3 kalyan k read 6666 i want to display record like this 1 vvk v math 4444 or 1 vvk v read 4444 here the sid and subject has composite primary key
hstudent.hbm.xml is: <composite-id> <key-property name="sid" column="sid" type="string"/> <key-property name="subject" column="subject" type="string"/> </composite-id> <property name="firstname" column="firstname" type="string"/> <property name="lastname" column="lastname" type="string"/> <property name="phno" column="phno" type="string"/>
my pojo class is: private String sid; private String firstname; private String lastname; private String subject; private String phno; public Student(String sid, String firstname, String lastname, String subject, String phno) { super(); this.sid=sid; this.firstname = firstname; this.lastname = lastname; this.subject = subject; this.phno = phno; } public String getSid() { return sid; } public void setSid(String sid) { this.sid = sid; } public String getFirstname() { return firstname; } public void setFirstname(String firstname) { this.firstname = firstname; } public String getLastname() { return lastname; } public void setLastname(String lastname) { this.lastname = lastname; } public String getSubject() { return subject; } public void setSubject(String subject) { this.subject = subject; } public String getPhno() { return phno; } public void setPhno(String phno) { this.phno = phno; } 1 vvk v math 4444 (or) 1 vvk v read 4444
here my question is how to write a query to display the above result
|