Question

I am working on a requirement. Currently there is a search page which has List Box with Values (Example Data) 1) Employee and 2) Sport Person.
Object Hierarchy (Hibernate Bean) Person is the actual Object which has two different class 1) Employee and 2) Sports Person based Discriminator Column
Person_Type (Discriminator Column).

On a search page , if user selects any of the list box, will result the data from that sub class.

Now requirement is to show both sub class result together and it is done by adding one more value in the list box as "Employee + Sports Person".

Problem's 1) Both sub class have different structure 2) There are other criteria which are compared with different attributes.

How can I union the two sub classes. Please help me to resolve. Please Note : I am trying not use Query Based Union. I am think in terms of OOPS

Was it helpful?

Solution

Loading both types of persons should not be a problem. If your query can access common attributes you can do FROM Person p WHERE <whatever_person_criteria_you_have>.

If your query need to use specific attributes of Employee and SportsPerson then you could execute 2 queries and put the result into a single List<Person>.

Sorting/displaying that list depends on what data needs to be displayed or compared. In case you have to compare different data, you could always use a Comparator<Person> which checks the actual class of the objects and maybe a wrapper which does the same to access the correct properties for display.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top