Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize exists queries #1243

Merged
merged 1 commit into from Mar 9, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -95,10 +95,4 @@ public boolean isPathInEntitiesSupported() {
return false;
}

@Override
public boolean isSelect1Supported() {
return true;
}


}
6 changes: 0 additions & 6 deletions querydsl-jpa/src/main/java/com/querydsl/jpa/HQLTemplates.java
Expand Up @@ -116,12 +116,6 @@ public String getExistsProjection() {
return "1";
}

@Override
public boolean isSelect1Supported() {
// TODO return true, when JPQLTemplates becomes standard
return false;
}

@Override
public boolean isEnumInPathSupported() {
// related : http://opensource.atlassian.com/projects/hibernate/browse/HHH-5159
Expand Down
Expand Up @@ -64,12 +64,7 @@ protected void reset() {

@Override
public boolean exists() {
if (templates.isSelect1Supported()) {
return singleResult(NumberTemplate.ONE) != null;
} else {
EntityPath<?> entityPath = (EntityPath<?>) queryMixin.getMetadata().getJoins().get(0).getTarget();
return !limit(1).list(entityPath).isEmpty();
}
return singleResult(NumberTemplate.ONE) != null;
}

public Q fetch() {
Expand Down
Expand Up @@ -158,10 +158,6 @@ public boolean isPathInEntitiesSupported() {
return true;
}

public boolean isSelect1Supported() {
return false;
}

@Nullable
public String getExistsProjection() {
return null;
Expand Down
Expand Up @@ -621,6 +621,7 @@ public void Enum_StartsWith() {
@Test
public void Exists() {
assertTrue(query().from(cat).where(cat.kittens.any().name.eq("Ruth123")).exists());
assertFalse(query().from(cat).where(cat.kittens.any().name.eq("Ruth321")).exists());
}

@Test
Expand Down