use of com.querydsl.jpa.JPQLSerializer in project querydsl by querydsl.
the class HibernateDeleteClause method toString.
@Override
public String toString() {
JPQLSerializer serializer = new JPQLSerializer(templates, null);
serializer.serializeForDelete(queryMixin.getMetadata());
return serializer.toString();
}
use of com.querydsl.jpa.JPQLSerializer in project querydsl by querydsl.
the class HibernateUpdateClause method toString.
@Override
public String toString() {
JPQLSerializer serializer = new JPQLSerializer(templates, null);
serializer.serializeForUpdate(queryMixin.getMetadata(), updates);
return serializer.toString();
}
use of com.querydsl.jpa.JPQLSerializer in project querydsl by querydsl.
the class JPADeleteClause method execute.
@Override
public long execute() {
JPQLSerializer serializer = new JPQLSerializer(templates, entityManager);
serializer.serializeForDelete(queryMixin.getMetadata());
Map<Object, String> constants = serializer.getConstantToLabel();
Query query = entityManager.createQuery(serializer.toString());
if (lockMode != null) {
query.setLockMode(lockMode);
}
JPAUtil.setConstants(query, constants, queryMixin.getMetadata().getParams());
return query.executeUpdate();
}
use of com.querydsl.jpa.JPQLSerializer in project querydsl by querydsl.
the class JPAUpdateClause method toString.
@Override
public String toString() {
JPQLSerializer serializer = new JPQLSerializer(templates, entityManager);
serializer.serializeForUpdate(queryMixin.getMetadata(), updates);
return serializer.toString();
}
use of com.querydsl.jpa.JPQLSerializer in project querydsl by querydsl.
the class AbstractJPAQuery method createQuery.
private Query createQuery(@Nullable QueryModifiers modifiers, boolean forCount) {
JPQLSerializer serializer = serialize(forCount);
String queryString = serializer.toString();
logQuery(queryString, serializer.getConstantToLabel());
Query query = entityManager.createQuery(queryString);
JPAUtil.setConstants(query, serializer.getConstantToLabel(), getMetadata().getParams());
if (modifiers != null && modifiers.isRestricting()) {
Integer limit = modifiers.getLimitAsInteger();
Integer offset = modifiers.getOffsetAsInteger();
if (limit != null) {
query.setMaxResults(limit);
}
if (offset != null) {
query.setFirstResult(offset);
}
}
if (lockMode != null) {
query.setLockMode(lockMode);
}
if (flushMode != null) {
query.setFlushMode(flushMode);
}
for (Map.Entry<String, Object> entry : hints.entries()) {
query.setHint(entry.getKey(), entry.getValue());
}
// set transformer, if necessary and possible
Expression<?> projection = getMetadata().getProjection();
// necessary when query is reused
this.projection = null;
if (!forCount && projection instanceof FactoryExpression) {
if (!queryHandler.transform(query, (FactoryExpression<?>) projection)) {
this.projection = (FactoryExpression) projection;
}
}
return query;
}
Aggregations