Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7822623
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T07:58:21+00:00 2026-06-02T07:58:21+00:00

I am working on some academic task and I’m stuck. The situation is as

  • 0

I am working on some academic task and I’m stuck. The situation is as follows:
I have three simple database tables and Java @Entity classes generated from them.

Table Mark:
STUDENT_ID (PK)
SUBJECT_ID (PK)
MARK

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;
(...)
}

Table Student:
INDEX_NO (PK)
FNAME
LNAME
FACULTY_ID

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<Mark> marksList1;
(...)
}

Table Student:
ID (PK)
NAME

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<Mark> marksList;
(...)
}

The task is to obtain two lists:
1. The list of students which does not have marks from all of the subjects yet.
2. The list of subjects from which particular student does not have a mark.

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.

So I am asking you for a help.
Thank you for your interest.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T07:58:23+00:00Added an answer on June 2, 2026 at 7:58 am

    I’m not sure if this is correct but maybe this can help you solve your issue. The size() function in JPQL can count a collection.

    These are 2 JPQL query’s

    1)

    select m.student
    from Mark m
    where size(m.subject) <> 
        size(select s from Subject s)
    

    2)

    select s
    from Subject s
    where s not in 
        (select m.s from Mark m where m.student.indexNo = :indexNo) 
    

    :indexNo is then the student’s id that should be set using a parameter.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Working with some basic java apps on CentOS 5 linux and I have my
I'm working some code that inserts csv rows into an SQLite database using Python.
I have some working code with a crutch to add BOM marker to a
Ive been working some time on own template engines but i alwais get stuck
i have attached TinyScrollBar(from [here] ) plugin with my project. It was working some
I've created a simple Facebook Reveal tab, which was working some time ago until
I am working on an academic research regarding some very long functions in the
I'm working some with a database and catching exceptions to check for various conditions.
I have some working JavaScript that I want to convert to pure jQuery. Please
Been working on some code streamlining and have realised that it would be really

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.