How to lazy fetch only parts of the children entity from the parent entity?

41
January 11, 2019, at 10:00 AM

I have a class Department that has a child entity Student. (Many to one relationship as a Department can have many students List<Student>.

The Student entity has many other child entities, fields like List<Address> and List<Classes>.

All entities are set to lazily initialized.

I want to get a single Department entity with only the names of its students. Without loading the children and grandchildren of student.

How to do that?

Methods I have tried:

  1. Hibernate.initialize(parent.getStudents()).
  2. Use join query: SELECT d s.name FROM department d LEFT JOIN FETCH d.students WHERE d.deptId = :dId.

They both does not work, problem is that the child components of Student is not loaded. Is there any ways to not load those components, only the name field of Student entity.

READ ALSO
How to call a method that has a JPanel over multiple instances in Java [on hold]

How to call a method that has a JPanel over multiple instances in Java [on hold]

I'm trying to make multiple objects with of a class (the Tic class), each with its own JPanel with buttons and stuffRight now when I make instances of the class they all add their buttons to the same JFrame

65
How to turn arg or string into User?

How to turn arg or string into User?

I am making a command and I need to get a list of roles for a user, the problem is that an argument is a string and getMember() expects a UserHow do I turn a string into a User or is there just a better way?

52
PDFBox: do PDDocument and PDPage have references to one another?

PDFBox: do PDDocument and PDPage have references to one another?

Does a PDPage object contains a reference to the PDDocument to which it belongs? In other words, does a PDPage has knowledge of its PDDocument? Somewhere in the application I have a list of PDDocumentsThese documents get merged into one new PDDocument:

58
How to send youtube-dl stdout to browser to save as a file?

How to send youtube-dl stdout to browser to save as a file?

I am making a php frontend for youtube-dlI am getting stdout from youtube-dl

37