79420061

Date: 2025-02-07 07:37:55
Score: 3.5
Natty:
Report link

Can you provide some background, why you want to have a result like this?

Actually if you want Dummy.name + List the most easiest way is to select the Dummyentities:

// Repo is a SpringData repository interface
Set<Dummy> result = repo.findAll();
final Map<String, List<SubEntity>> collect = result.stream().collect(Collectors.toMap(Dummy::getName, Dummy::getSubs));

In case you want to use criteria queries for filtering by subentity-property, just add this to the findAll, might look like this:

 // Not really tested...            
 Set<Dummy> result = repo.findAll( (root, query, cb) -> 
    query.where(cb.equal(root.get(Dummy_.SUBS).get(Sub_.SOMEPROP), cb.literal("some-value"));

final Map<String, List<SubEntity>> collect = result.stream().collect(Collectors.toMap(Dummy::getName, Dummy::getSubs));

Alternatively use entity-manager + create query etc. to const

Reasons:
  • RegEx Blacklisted phrase (2.5): Can you provide some
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Contains question mark (0.5):
  • Starts with a question (0.5): Can you
  • Low reputation (1):
Posted by: Peter Vigier