mirror of
https://github.com/querydsl/querydsl.git
synced 2026-07-03 21:07:49 +08:00
Respect the user-specified existing templates during JPAQuery.clone()
This commit is contained in:
parent
719eb82247
commit
3f2ca5ccad
@ -355,13 +355,28 @@ public abstract class AbstractJPAQuery<Q extends AbstractJPAQuery<Q>> extends JP
|
||||
*/
|
||||
public abstract Q clone(EntityManager entityManager);
|
||||
|
||||
/**
|
||||
* Clone the state of this query to a new instance with the given EntityManager
|
||||
* using the specified templates
|
||||
*
|
||||
* @param entityManager
|
||||
* @param templates
|
||||
* @return
|
||||
*/
|
||||
public abstract Q clone(EntityManager entityManager, JPQLTemplates templates);
|
||||
|
||||
/**
|
||||
* Clone the state of this query to a new instance
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Q clone() {
|
||||
return this.clone(this.entityManager);
|
||||
JPQLTemplates existingTemplates = getTemplates();
|
||||
if (existingTemplates != null) {
|
||||
return clone(entityManager, existingTemplates);
|
||||
}else {
|
||||
return clone(entityManager);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -74,10 +74,16 @@ public class JPAQuery extends AbstractJPAQuery<JPAQuery> {
|
||||
super(em, templates, metadata);
|
||||
}
|
||||
|
||||
public JPAQuery clone(EntityManager entityManager) {
|
||||
JPAQuery q = new JPAQuery(entityManager, JPAProvider.getTemplates(entityManager), getMetadata().clone());
|
||||
@Override
|
||||
public JPAQuery clone(EntityManager entityManager, JPQLTemplates templates) {
|
||||
JPAQuery q = new JPAQuery(entityManager, templates, getMetadata().clone());
|
||||
q.clone(this);
|
||||
return q;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JPAQuery clone(EntityManager entityManager) {
|
||||
return clone(entityManager, JPAProvider.getTemplates(entityManager));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user