Add more queryFactory constructors

This commit is contained in:
Timo Westkämper 2015-05-24 22:25:41 +03:00
parent 60c46b1d71
commit db21ee36e2
2 changed files with 34 additions and 0 deletions

View File

@ -37,6 +37,20 @@ public class HibernateQueryFactory implements JPQLQueryFactory {
private final Provider<Session> session;
public HibernateQueryFactory(Session session) {
this(HQLTemplates.DEFAULT, session);
}
public HibernateQueryFactory(JPQLTemplates templates, final Session session) {
this.session = new Provider<Session>() {
@Override
public Session get() {
return session;
}
};
this.templates = templates;
}
public HibernateQueryFactory(Provider<Session> session) {
this(HQLTemplates.DEFAULT, session);
}

View File

@ -37,6 +37,26 @@ public class JPAQueryFactory implements JPQLQueryFactory {
private final Provider<EntityManager> entityManager;
public JPAQueryFactory(final EntityManager entityManager) {
this.entityManager = new Provider<EntityManager>() {
@Override
public EntityManager get() {
return entityManager;
}
};
this.templates = null;
}
public JPAQueryFactory(JPQLTemplates templates, final EntityManager entityManager) {
this.entityManager = new Provider<EntityManager>() {
@Override
public EntityManager get() {
return entityManager;
}
};
this.templates = templates;
}
public JPAQueryFactory(Provider<EntityManager> entityManager) {
this.entityManager = entityManager;
this.templates = null;