well...I can acess the current EM with:
final JPAQuery<Configuration> qry = new JPAQuery<Configuration>(
*entityManager()*).from(c)
.where(c.key.eq(key));
so I don't need to inject the context.
I don't need a fancy delegate.
On Thu, Feb 8, 2018 at 3:39 PM, Luís Alves <[email protected]> wrote:
> Hello,
>
> I'm trying to user QueryDSL. From the examples at
> https://deltaspike.apache.org/documentation/data.html
>
> O got to something like this:
>
> @Repository
> public abstract class ConfigurationRepository extends
> AbstractEntityRepository<Configuration, Integer>
> implements EntityRepository<Configuration, Integer>,
> EntityManagerDelegate<Configuration>
> {
>
> @Inject
> private QueryInvocationContext context;
>
> /**
> * Find by key.
> *
> * @param key
> * the key
> * @return the configuration
> */
> public Configuration getByKey(String key)
> {
> final QConfiguration c = QConfiguration.configuration;
>
> final JPAQuery<Configuration> qry = new JPAQuery<Configuration>(
> context.getEntityManager()).from(c)
> .where(c.key.eq(key));
> return qry.fetchFirst();
> }
> }
>
> The problem is that the context is null. Am I missing something? Do we
> need to be inside a TX? Currently I'm invoking like:
>
> @Transactional(value = TxType.SUPPORTS)
> public void findConfig()
> {
> final Configuration c = configurationRepository.
> getByKey("b6ace366-5678-41dd-ba44-5126cb40c7d9");
> }
>
> Regards,
> LA
>