Note that there are some explanatory texts on larger screens.

plurals
  1. POJPA query for given task
    primarykey
    data
    text
    <p>I am working on some academic task and I'm stuck. The situation is as follows:<br> I have three simple database tables and Java @Entity classes generated from them.</p> <p>Table Mark:<br> STUDENT_ID (PK)<br> SUBJECT_ID (PK)<br> MARK<br></p> <pre><code>public class Mark implements Serializable { private BigDecimal mark; @Id @Column(name = "STUDENT_ID", nullable = false, insertable = false, updatable = false) private BigDecimal studentId; @Id @Column(name = "SUBJECT_ID", nullable = false, insertable = false, updatable = false) private BigDecimal subjectId; @ManyToOne @JoinColumn(name = "SUBJECT_ID") private Subject subject; @ManyToOne @JoinColumn(name = "STUDENT_ID") private Student student; (...) } </code></pre> <p>Table Student:<br> INDEX_NO (PK)<br> FNAME<br> LNAME<br> FACULTY_ID<br></p> <pre><code>public class Student implements Serializable { @Column(name = "FACULTY_ID", nullable = false) private BigDecimal facultyId; @Column(nullable = false, length = 20) private String fname; @Id @Column(name = "INDEX_NO", nullable = false) private BigDecimal indexNo; @Column(nullable = false, length = 20) private String lname; @OneToMany(mappedBy = "student") private List&lt;Mark&gt; marksList1; (...) } </code></pre> <p>Table Student:<br> ID (PK)<br> NAME<br></p> <pre><code>public class Subject implements Serializable { @Id @Column(nullable = false) private BigDecimal id; @Column(nullable = false, length = 60) private String name; @OneToMany(mappedBy = "subject") private List&lt;Mark&gt; marksList; (...) } </code></pre> <p>The task is to obtain two lists:<br> 1. The list of students which does not have marks from all of the subjects yet.<br> 2. The list of subjects from which particular student does not have a mark.<br></p> <p>I am not too good at SQL, so I have problem with query construction. It can be solved by any JPA-like way, i.e. JPQL, Criteria API.</p> <p>So I am asking you for a help.<br> Thank you for your interest.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload