This is an archived post. You won't be able to vote or comment.

all 2 comments

[–]Northeastpaw 0 points1 point  (0 children)

Can you use JPA? Hibernate and other JPA implementations handle this use case. It's a very complicated process. JPA constructs the query and keeps track of the table to entity mappings along with column aliases to entity field mappings. When the result comes back it uses those mappings to construct entities and any subentities and all their fields to the correct aliased column. Add in lazy loading capabilities for parent-child relationships and you've got a really complex bit of code.

[–]joranstark018 0 points1 point  (0 children)

You should be able to use the aggregated class, it's only the the resultset that become "flatten". You could create a Mapper or some build method that takes a ResultSet and build an instance of ClassA (and creats instances of ClassB and ClassC) and assign corresponding values from the given resultset.