@PersistenceContext
private EntityManager entityManager;
Thanks for any ideas you guys can give me.
Oh. I'm using Querydsl 4.0.0 btw.
--
You received this message because you are subscribed to the Google Groups "Querydsl" group.
To unsubscribe from this group and stop receiving emails from it, send an email to querydsl+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
I couldn't make that work.From what I'm seeing here, entityManager is not a spring bean I can just inject anywhere.When I do what you said, I get a "No qualifying bean of type ..." exception from Spring. The Spring way (actually I think it's the JPA way) of getting EntityManager is thru @PersistenceContext. I may be wrong since I'm very new to this whole JPA specification.I'm already using Querydsl, but with new JPAQuery(em) but I want to use it the recommended way.I'll find some time to make a small project to show this example and post it here.Thanks for the help so far. =)
On Sun, Jun 7, 2015 at 4:49 PM, timowest via Querydsl <querydsl+APn2wQefkk7kI02e0xPnNp6yrNOiXUEZ44_gIyQiFakJHtII_UP_1p5@googlegroups.com> wrote:
You can inject a single JPAQueryFactory instance and use the following constructor to create it@Beanpublic JPAQueryFactory jpaQueryFactory() {return new JPAQueryFactory(entityManager);}Timo
On Sunday, June 7, 2015 at 4:11:11 AM UTC+3, fasfsfgs wrote:Oh. I'm using Querydsl 4.0.0 btw.On Sat, Jun 6, 2015 at 10:06 PM, fasfsfgs wrote:Hello Querydsl people!I've been using an old version of Querydsl for a couple years and now I'm finally upgrading my environment. One of the updates I'm doing is Querydsl.I have already successfully done the upgrade and after reading the docs, Querydsl suggests using JPAQueryFactory to get JPAQuery instances.My questions is: What is the best practice to do this inside my DAOs?I'm using Spring to provide me the entity manager.@PersistenceContext
private EntityManager entityManager;Thanks for any ideas you guys can give me.
--
You received this message because you are subscribed to the Google Groups "Querydsl" group.
To unsubscribe from this group and stop receiving emails from it, send an email to querydsl+unsubscribe@googlegroups.com.
@Configuration
public class QuerydslConfig {
@PersistenceContext
private EntityManager em;
@Bean
public JPAQueryFactory getJPAQueryFactory() {
Provider<EntityManager> provider = new Provider<EntityManager>() {
@Override
public EntityManager get() {
return em;
}
};
return new JPAQueryFactory(provider);
}
}
@PersistenceContext
private Provider<EntityManager> em;
Caused by: java.lang.IllegalStateException: Specified field type [interface javax.inject.Provider] is incompatible with resource type [javax.persistence.EntityManager]
@Inject
private Provider<EntityManager> em;
org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [javax.persistence.EntityManager] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency.
How did you inject the EntityManager into the JPAQueryFactory? Also could you provide the full error message?Did you try something like@Configurationpublic class QuerydslConfiguration {@PersistenceContextprivate EntityManager entityManager;@Beanpublic JPAQueryFactory jpaQueryFactory() {return new JPAQueryFactory(entityManager);}
}
On Monday, June 8, 2015 at 1:47:25 AM UTC+3, fasfsfgs wrote:
I couldn't make that work.From what I'm seeing here, entityManager is not a spring bean I can just inject anywhere.When I do what you said, I get a "No qualifying bean of type ..." exception from Spring. The Spring way (actually I think it's the JPA way) of getting EntityManager is thru @PersistenceContext. I may be wrong since I'm very new to this whole JPA specification.I'm already using Querydsl, but with new JPAQuery(em) but I want to use it the recommended way.I'll find some time to make a small project to show this example and post it here.Thanks for the help so far. =)
On Sun, Jun 7, 2015 at 4:49 PM, timowest via Querydsl <querydsl+APn2wQefkk7kI02e0xPnNp6...@googlegroups.com> wrote:
You can inject a single JPAQueryFactory instance and use the following constructor to create it@Beanpublic JPAQueryFactory jpaQueryFactory() {return new JPAQueryFactory(entityManager);}Timo
On Sunday, June 7, 2015 at 4:11:11 AM UTC+3, fasfsfgs wrote:Oh. I'm using Querydsl 4.0.0 btw.On Sat, Jun 6, 2015 at 10:06 PM, fasfsfgs wrote:Hello Querydsl people!I've been using an old version of Querydsl for a couple years and now I'm finally upgrading my environment. One of the updates I'm doing is Querydsl.I have already successfully done the upgrade and after reading the docs, Querydsl suggests using JPAQueryFactory to get JPAQuery instances.My questions is: What is the best practice to do this inside my DAOs?I'm using Spring to provide me the entity manager.@PersistenceContext
private EntityManager entityManager;Thanks for any ideas you guys can give me.
--
You received this message because you are subscribed to the Google Groups "Querydsl" group.
To unsubscribe from this group and stop receiving emails from it, send an email to querydsl+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Querydsl" group.
To unsubscribe from this group and stop receiving emails from it, send an email to querydsl+u...@googlegroups.com.