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