Title: jpa criteria query fails after MapJoin
Tags: jpa;jpa-2.0;criteria;criteria-api
Question: I have the following @Entities
@Entity
public class Configuration{
@OneToMany
protected Map<String, Component&gt; components;
@Entity
public class Component{
protected String displayName;
}
I do not understand why this works, returning all Configurations
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<Configuration&gt; cq = cb.createQuery(Configuration.class);
Root<Configuration&gt; pc = cq.from(Configuration.class);
cq.select(pc);
But if I do a MapJoin, even without setting any conditions, it does not return anything
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<Configuration&gt; cq = cb.createQuery(Configuration.class);
Root<Configuration&gt; pc = cq.from(Configuration.class);
MapJoin<Configuration, String, Component&gt; mapJoin = pc.join(Configuration_.components);
cq.select(pc);
What am I missing? I'm at a loss, I've been through the tutorials, but have not found the answers I need. Any help much appreciated.

Here is the accepted answer: Because the join type is inner by default, which means that for a configuration to be returned it has to at least have one component. If none of your configurations have a component, nothing is returned.
The first query is equivalent to
select configuration.* from configuration
And the second one is equivalent to
select configuration.* from configuration
inner join component on component.id = configuration.id


{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 1, 'CommentCount': 0, 'ContentLicense': 'CC BY-SA 3.0', 'CreationDate': '2012:00:02/05/12', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<jpa><jpa-2.0><criteria><criteria-api>', 'Title': 'jpa criteria query fails after MapJoin', 'ViewCount': 393, 'id': 9151143, 'user_AboutMe': '<p>web developer</p>\n', 'user_AccountId': 1009049.0, 'user_DisplayName': 'glasspill', 'user_Reputation': 1269.0, 'user_Views': 130.0, 'user_id': 1022043.0}}