com.querydsl.jpa.JPAQueryBase Maven / Gradle / Ivy
/*
* Copyright 2015, The Querydsl Team (http://www.querydsl.com/team)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.querydsl.jpa;
import com.querydsl.core.QueryMetadata;
import com.querydsl.core.support.FetchableSubQueryBase;
import com.querydsl.core.types.*;
import com.querydsl.core.types.dsl.Expressions;
/**
* {@code JPAQueryBase} is a base Query class for JPA queries
*
* @author tiwe
*/
public abstract class JPAQueryBase> extends FetchableSubQueryBase implements JPQLQuery {
protected final JPAQueryMixin queryMixin;
private final JPQLTemplates templates;
@SuppressWarnings("unchecked")
public JPAQueryBase(QueryMetadata md, JPQLTemplates templates) {
super(new JPAQueryMixin(md));
super.queryMixin.setSelf((Q) this);
this.queryMixin = (JPAQueryMixin) super.queryMixin;
this.templates = templates;
}
protected JPQLTemplates getTemplates() {
return templates;
}
protected abstract JPQLSerializer createSerializer();
protected JPQLSerializer serialize(boolean forCountRow) {
if (queryMixin.getMetadata().getJoins().isEmpty()) {
throw new IllegalArgumentException("No joins given");
}
JPQLSerializer serializer = createSerializer();
serializer.serialize(queryMixin.getMetadata(), forCountRow, null);
return serializer;
}
protected void reset() {
queryMixin.getMetadata().reset();
}
@Override
public Q fetchJoin() {
return queryMixin.fetchJoin();
}
@Override
public Q fetchAll() {
return queryMixin.fetchAll();
}
public Q from(EntityPath> arg) {
return queryMixin.from(arg);
}
@Override
public Q from(EntityPath>... args) {
return queryMixin.from(args);
}
@Override
public Q from(CollectionExpression,P> target, Path
alias) {
return queryMixin.from(Expressions.as((Path)target, alias));
}
@Override
public
Q innerJoin(CollectionExpression,P> target) {
return queryMixin.innerJoin(target);
}
@Override
public
Q innerJoin(CollectionExpression,P>target, Path
alias) {
return queryMixin.innerJoin(target, alias);
}
@Override
public
Q innerJoin(EntityPath
target) {
return queryMixin.innerJoin(target);
}
@Override
public
Q innerJoin(EntityPath
target, Path
alias) {
return queryMixin.innerJoin(target, alias);
}
@Override
public
Q innerJoin(MapExpression,P> target) {
return queryMixin.innerJoin(target);
}
@Override
public
Q innerJoin(MapExpression,P> target, Path
alias) {
return queryMixin.innerJoin(target, alias);
}
@Override
public
Q join(CollectionExpression,P> target) {
return queryMixin.join(target);
}
@Override
public
Q join(CollectionExpression,P> target, Path
alias) {
return queryMixin.join(target, alias);
}
@Override
public
Q join(EntityPath
target) {
return queryMixin.join(target);
}
@Override
public
Q join(EntityPath
target, Path
alias) {
return queryMixin.join(target, alias);
}
@Override
public
Q join(MapExpression,P> target) {
return queryMixin.join(target);
}
@Override
public
Q join(MapExpression,P> target, Path
alias) {
return queryMixin.join(target, alias);
}
@Override
public
Q leftJoin(CollectionExpression,P> target) {
return queryMixin.leftJoin(target);
}
@Override
public
Q leftJoin(CollectionExpression,P> target, Path
alias) {
return queryMixin.leftJoin(target, alias);
}
@Override
public
Q leftJoin(EntityPath
target) {
return queryMixin.leftJoin(target);
}
@Override
public
Q leftJoin(EntityPath
target, Path
alias) {
return queryMixin.leftJoin(target, alias);
}
@Override
public
Q leftJoin(MapExpression,P> target) {
return queryMixin.leftJoin(target);
}
@Override
public
Q leftJoin(MapExpression,P> target, Path
alias) {
return queryMixin.leftJoin(target, alias);
}
@Override
public
Q rightJoin(CollectionExpression,P> target) {
return queryMixin.rightJoin(target);
}
@Override
public
Q rightJoin(CollectionExpression,P> target, Path
alias) {
return queryMixin.rightJoin(target, alias);
}
@Override
public
Q rightJoin(EntityPath
target) {
return queryMixin.rightJoin(target);
}
@Override
public
Q rightJoin(EntityPath
target, Path
alias) {
return queryMixin.rightJoin(target, alias);
}
@Override
public
Q rightJoin(MapExpression,P> target) {
return queryMixin.rightJoin(target);
}
@Override
public
Q rightJoin(MapExpression,P> target, Path
alias) {
return queryMixin.rightJoin(target, alias);
}
public Q on(Predicate condition) {
return queryMixin.on(condition);
}
@Override
public Q on(Predicate... conditions) {
return queryMixin.on(conditions);
}
@Override
public String toString() {
JPQLSerializer serializer = serialize(false);
return serializer.toString().trim();
}
@Override
public abstract Q clone();
}