Search in sources :

Example 6 with JPQLSerializer

use of com.querydsl.jpa.JPQLSerializer in project querydsl by querydsl.

the class JPADeleteClause method toString.

@Override
public String toString() {
    JPQLSerializer serializer = new JPQLSerializer(templates, entityManager);
    serializer.serializeForDelete(queryMixin.getMetadata());
    return serializer.toString();
}
Also used : JPQLSerializer(com.querydsl.jpa.JPQLSerializer)

Example 7 with JPQLSerializer

use of com.querydsl.jpa.JPQLSerializer in project querydsl by querydsl.

the class JPAUpdateClause method execute.

@Override
public long execute() {
    JPQLSerializer serializer = new JPQLSerializer(templates, entityManager);
    serializer.serializeForUpdate(queryMixin.getMetadata(), updates);
    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();
}
Also used : Query(javax.persistence.Query) JPQLSerializer(com.querydsl.jpa.JPQLSerializer)

Example 8 with JPQLSerializer

use of com.querydsl.jpa.JPQLSerializer in project querydsl by querydsl.

the class HibernateDeleteClause method execute.

@Override
public long execute() {
    JPQLSerializer serializer = new JPQLSerializer(templates, null);
    serializer.serializeForDelete(queryMixin.getMetadata());
    Map<Object, String> constants = serializer.getConstantToLabel();
    Query query = session.createQuery(serializer.toString());
    for (Map.Entry<Path<?>, LockMode> entry : lockModes.entrySet()) {
        query.setLockMode(entry.getKey().toString(), entry.getValue());
    }
    HibernateUtil.setConstants(query, constants, queryMixin.getMetadata().getParams());
    return query.executeUpdate();
}
Also used : Path(com.querydsl.core.types.Path) EntityPath(com.querydsl.core.types.EntityPath) Query(org.hibernate.Query) JPQLSerializer(com.querydsl.jpa.JPQLSerializer) LockMode(org.hibernate.LockMode) HashMap(java.util.HashMap) Map(java.util.Map)

Example 9 with JPQLSerializer

use of com.querydsl.jpa.JPQLSerializer in project querydsl by querydsl.

the class HibernateUpdateClause method execute.

@Override
public long execute() {
    JPQLSerializer serializer = new JPQLSerializer(templates, null);
    serializer.serializeForUpdate(queryMixin.getMetadata(), updates);
    Map<Object, String> constants = serializer.getConstantToLabel();
    Query query = session.createQuery(serializer.toString());
    for (Map.Entry<Path<?>, LockMode> entry : lockModes.entrySet()) {
        query.setLockMode(entry.getKey().toString(), entry.getValue());
    }
    HibernateUtil.setConstants(query, constants, queryMixin.getMetadata().getParams());
    return query.executeUpdate();
}
Also used : Path(com.querydsl.core.types.Path) EntityPath(com.querydsl.core.types.EntityPath) Query(org.hibernate.Query) JPQLSerializer(com.querydsl.jpa.JPQLSerializer) LockMode(org.hibernate.LockMode) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

JPQLSerializer (com.querydsl.jpa.JPQLSerializer)9 Map (java.util.Map)3 Query (javax.persistence.Query)3 EntityPath (com.querydsl.core.types.EntityPath)2 Path (com.querydsl.core.types.Path)2 HashMap (java.util.HashMap)2 LockMode (org.hibernate.LockMode)2 Query (org.hibernate.Query)2 FactoryExpression (com.querydsl.core.types.FactoryExpression)1