org.apache.deltaspike.data.api.Query类的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(10.8k)|赞(0)|评价(0)|浏览(197)

本文整理了Java中org.apache.deltaspike.data.api.Query类的一些代码示例,展示了Query类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query类的具体详情如下:
包路径:org.apache.deltaspike.data.api.Query
类名称:Query

Query介绍

暂无

代码示例

代码示例来源:origin: com.blazebit/blaze-persistence-integration-deltaspike-data-impl

  1. private QueryHint[] extractQueryHints(Method method) {
  2. Class<org.apache.deltaspike.data.api.Query> query = org.apache.deltaspike.data.api.Query.class;
  3. if (method.isAnnotationPresent(query) &&
  4. method.getAnnotation(query).hints().length > 0) {
  5. return method.getAnnotation(query).hints();
  6. }
  7. return null;
  8. }

代码示例来源:origin: com.blazebit/blaze-persistence-integration-deltaspike-data-impl

  1. private LockModeType extractLockMode(Method method) {
  2. Class<org.apache.deltaspike.data.api.Query> query = org.apache.deltaspike.data.api.Query.class;
  3. if (method.isAnnotationPresent(query) &&
  4. method.getAnnotation(query).lock() != LockModeType.NONE) {
  5. return method.getAnnotation(query).lock();
  6. }
  7. return null;
  8. }

代码示例来源:origin: com.blazebit/blaze-persistence-integration-deltaspike-data-impl

  1. private static int extractSizeRestriction(Method method, EntityViewRepositoryMethod repositoryMethod) {
  2. if (method.isAnnotationPresent(org.apache.deltaspike.data.api.Query.class)) {
  3. return method.getAnnotation(org.apache.deltaspike.data.api.Query.class).max();
  4. }
  5. return repositoryMethod.getDefinedMaxResults();
  6. }

代码示例来源:origin: org.apache.deltaspike.modules/deltaspike-data-module-impl

  1. private boolean isValid(Query query)
  2. {
  3. return isNotEmpty(query.value()) || isNotEmpty(query.named());
  4. }

代码示例来源:origin: Blazebit/blaze-persistence

  1. private javax.persistence.Query createJpaQuery(Query query, CdiQueryInvocationContext context) {
  2. EntityManager entityManager = context.getEntityManager();
  3. Parameters params = context.getParams();
  4. javax.persistence.Query result = null;
  5. if (isNotEmpty(query.named())) {
  6. if (context.hasQueryStringPostProcessors()) {
  7. javax.persistence.Query namedQuery = entityManager.createNamedQuery(query.named());
  8. String named = factory.extract(namedQuery);
  9. String jpqlQuery = context.applyQueryStringPostProcessors(named);
  10. result = params.applyTo(entityManager.createQuery(jpqlQuery));
  11. } else {
  12. result = params.applyTo(entityManager.createNamedQuery(query.named()));
  13. }
  14. } else if (query.isNative()) {
  15. String jpqlQuery = context.applyQueryStringPostProcessors(query.value());
  16. Class<?> resultType = getQueryResultType(context.getMethod());
  17. if (isEntityType(resultType)) {
  18. result = params.applyTo(entityManager.createNativeQuery(jpqlQuery, resultType));
  19. } else {
  20. result = params.applyTo(entityManager.createNativeQuery(jpqlQuery));
  21. }
  22. } else {
  23. String jpqlQuery = context.applyQueryStringPostProcessors(query.value());
  24. context.setQueryString(jpqlQuery);
  25. result = params.applyTo(entityManager.createQuery(jpqlQuery));
  26. }
  27. return context.applyRestrictions(result);
  28. }

代码示例来源:origin: com.blazebit/blaze-persistence-integration-deltaspike-data-impl-1.8

  1. private void initSingleResultType(RepositoryMethodMetadata repositoryMethodMetadata) {
  2. SingleResultType singleResultType = repositoryMethodMetadata.getQuery() != null
  3. ? repositoryMethodMetadata.getQuery().singleResult()
  4. : repositoryMethodMetadata.getMethodPrefix().getSingleResultStyle();
  5. if (repositoryMethodMetadata.isReturnsOptional() && singleResultType == SingleResultType.JPA) {
  6. repositoryMethodMetadata.setSingleResultType(SingleResultType.OPTIONAL);
  7. } else {
  8. repositoryMethodMetadata.setSingleResultType(singleResultType);
  9. }
  10. }

代码示例来源:origin: com.blazebit/blaze-persistence-integration-deltaspike-data-impl-1.8

  1. private javax.persistence.Query createJpaQuery(Query query, CdiQueryInvocationContext context) {
  2. EntityManager entityManager = context.getEntityManager();
  3. Parameters params = context.getParams();
  4. javax.persistence.Query result = null;
  5. if (isNotEmpty(query.named())) {
  6. if (context.hasQueryStringPostProcessors()) {
  7. javax.persistence.Query namedQuery = entityManager.createNamedQuery(query.named());
  8. String named = factory.extract(namedQuery);
  9. String jpqlQuery = context.applyQueryStringPostProcessors(named);
  10. result = params.applyTo(entityManager.createQuery(jpqlQuery));
  11. } else {
  12. result = params.applyTo(entityManager.createNamedQuery(query.named()));
  13. }
  14. } else if (query.isNative()) {
  15. String jpqlQuery = context.applyQueryStringPostProcessors(query.value());
  16. Class<?> resultType = getQueryResultType(context.getMethod());
  17. if (isEntityType(resultType)) {
  18. result = params.applyTo(entityManager.createNativeQuery(jpqlQuery, resultType));
  19. } else {
  20. result = params.applyTo(entityManager.createNativeQuery(jpqlQuery));
  21. }
  22. } else {
  23. String jpqlQuery = context.applyQueryStringPostProcessors(query.value());
  24. context.setQueryString(jpqlQuery);
  25. result = params.applyTo(entityManager.createQuery(jpqlQuery));
  26. }
  27. return context.applyRestrictions(result);
  28. }

代码示例来源:origin: com.blazebit/blaze-persistence-integration-deltaspike-data-impl-1.7

  1. private boolean isValid(Query query) {
  2. return isNotEmpty(query.value()) || isNotEmpty(query.named());
  3. }

代码示例来源:origin: Blazebit/blaze-persistence

  1. private void initSingleResultType(RepositoryMethodMetadata repositoryMethodMetadata) {
  2. SingleResultType singleResultType = repositoryMethodMetadata.getQuery() != null
  3. ? repositoryMethodMetadata.getQuery().singleResult()
  4. : repositoryMethodMetadata.getMethodPrefix().getSingleResultStyle();
  5. if (repositoryMethodMetadata.isReturnsOptional() && singleResultType == SingleResultType.JPA) {
  6. repositoryMethodMetadata.setSingleResultType(SingleResultType.OPTIONAL);
  7. } else {
  8. repositoryMethodMetadata.setSingleResultType(singleResultType);
  9. }
  10. }

代码示例来源:origin: com.blazebit/blaze-persistence-integration-deltaspike-data-impl-1.7

  1. private javax.persistence.Query createJpaQuery(Query query, EntityViewCdiQueryInvocationContext context) {
  2. EntityManager entityManager = context.getEntityManager();
  3. ExtendedParameters params = context.getParams();
  4. javax.persistence.Query result = null;
  5. if (isNotEmpty(query.named())) {
  6. if (context.hasQueryStringPostProcessors()) {
  7. javax.persistence.Query namedQuery = entityManager.createNamedQuery(query.named());
  8. String named = factory.extract(namedQuery);
  9. String jpqlQuery = context.applyQueryStringPostProcessors(named);
  10. result = params.applyTo(entityManager.createQuery(jpqlQuery));
  11. } else {
  12. result = params.applyTo(entityManager.createNamedQuery(query.named()));
  13. }
  14. } else if (query.isNative()) {
  15. String jpqlQuery = context.applyQueryStringPostProcessors(query.value());
  16. Class<?> resultType = getQueryResultType(context.getMethod());
  17. if (isEntityType(resultType)) {
  18. result = params.applyTo(entityManager.createNativeQuery(jpqlQuery, resultType));
  19. } else {
  20. result = params.applyTo(entityManager.createNativeQuery(jpqlQuery));
  21. }
  22. } else {
  23. String jpqlQuery = context.applyQueryStringPostProcessors(query.value());
  24. context.setQueryString(jpqlQuery);
  25. result = params.applyTo(entityManager.createQuery(jpqlQuery));
  26. }
  27. return context.applyRestrictions(result);
  28. }

代码示例来源:origin: com.blazebit/blaze-persistence-integration-deltaspike-data-impl-1.7

  1. private LockModeType extractLockMode(Method method) {
  2. Class<org.apache.deltaspike.data.api.Query> query = org.apache.deltaspike.data.api.Query.class;
  3. if (method.isAnnotationPresent(query) &&
  4. method.getAnnotation(query).lock() != LockModeType.NONE) {
  5. return method.getAnnotation(query).lock();
  6. }
  7. return null;
  8. }

代码示例来源:origin: com.blazebit/blaze-persistence-integration-deltaspike-data-impl-1.8

  1. private boolean isValid(Query query) {
  2. return isNotEmpty(query.value()) || isNotEmpty(query.named());
  3. }

代码示例来源:origin: com.blazebit/blaze-persistence-integration-deltaspike-data-impl-1.7

  1. private QueryHint[] extractQueryHints(Method method) {
  2. Class<org.apache.deltaspike.data.api.Query> query = org.apache.deltaspike.data.api.Query.class;
  3. if (method.isAnnotationPresent(query) &&
  4. method.getAnnotation(query).hints().length > 0) {
  5. return method.getAnnotation(query).hints();
  6. }
  7. return null;
  8. }

代码示例来源:origin: com.blazebit/blaze-persistence-integration-deltaspike-data-impl-1.7

  1. private static int extractSizeRestriction(Method method, RepositoryMethod repositoryMethod) {
  2. if (method.isAnnotationPresent(org.apache.deltaspike.data.api.Query.class)) {
  3. return method.getAnnotation(org.apache.deltaspike.data.api.Query.class).max();
  4. }
  5. return repositoryMethod.getDefinedMaxResults();
  6. }

代码示例来源:origin: org.apache.deltaspike.modules/deltaspike-data-module-impl

  1. private void initSingleResultType(RepositoryMethodMetadata repositoryMethodMetadata)
  2. {
  3. SingleResultType singleResultType = repositoryMethodMetadata.getQuery() != null
  4. ? repositoryMethodMetadata.getQuery().singleResult()
  5. : repositoryMethodMetadata.getMethodPrefix().getSingleResultStyle();
  6. if (repositoryMethodMetadata.isReturnsOptional() && singleResultType == SingleResultType.JPA)
  7. {
  8. repositoryMethodMetadata.setSingleResultType(SingleResultType.OPTIONAL);
  9. }
  10. else
  11. {
  12. repositoryMethodMetadata.setSingleResultType(singleResultType);
  13. }
  14. }

代码示例来源:origin: Blazebit/blaze-persistence

  1. private javax.persistence.Query createJpaQuery(Query query, EntityViewCdiQueryInvocationContext context) {
  2. EntityManager entityManager = context.getEntityManager();
  3. ExtendedParameters params = context.getParams();
  4. javax.persistence.Query result = null;
  5. if (isNotEmpty(query.named())) {
  6. if (context.hasQueryStringPostProcessors()) {
  7. javax.persistence.Query namedQuery = entityManager.createNamedQuery(query.named());
  8. String named = factory.extract(namedQuery);
  9. String jpqlQuery = context.applyQueryStringPostProcessors(named);
  10. result = params.applyTo(entityManager.createQuery(jpqlQuery));
  11. } else {
  12. result = params.applyTo(entityManager.createNamedQuery(query.named()));
  13. }
  14. } else if (query.isNative()) {
  15. String jpqlQuery = context.applyQueryStringPostProcessors(query.value());
  16. Class<?> resultType = getQueryResultType(context.getMethod());
  17. if (isEntityType(resultType)) {
  18. result = params.applyTo(entityManager.createNativeQuery(jpqlQuery, resultType));
  19. } else {
  20. result = params.applyTo(entityManager.createNativeQuery(jpqlQuery));
  21. }
  22. } else {
  23. String jpqlQuery = context.applyQueryStringPostProcessors(query.value());
  24. context.setQueryString(jpqlQuery);
  25. result = params.applyTo(entityManager.createQuery(jpqlQuery));
  26. }
  27. return context.applyRestrictions(result);
  28. }

代码示例来源:origin: Blazebit/blaze-persistence

  1. private LockModeType extractLockMode(Method method) {
  2. Class<org.apache.deltaspike.data.api.Query> query = org.apache.deltaspike.data.api.Query.class;
  3. if (method.isAnnotationPresent(query) &&
  4. method.getAnnotation(query).lock() != LockModeType.NONE) {
  5. return method.getAnnotation(query).lock();
  6. }
  7. return null;
  8. }

代码示例来源:origin: Blazebit/blaze-persistence

  1. private boolean isValid(Query query) {
  2. return isNotEmpty(query.value()) || isNotEmpty(query.named());
  3. }

代码示例来源:origin: Blazebit/blaze-persistence

  1. private QueryHint[] extractQueryHints(Method method) {
  2. Class<org.apache.deltaspike.data.api.Query> query = org.apache.deltaspike.data.api.Query.class;
  3. if (method.isAnnotationPresent(query) &&
  4. method.getAnnotation(query).hints().length > 0) {
  5. return method.getAnnotation(query).hints();
  6. }
  7. return null;
  8. }

代码示例来源:origin: Blazebit/blaze-persistence

  1. private static int extractSizeRestriction(Method method, RepositoryMethod repositoryMethod) {
  2. if (method.isAnnotationPresent(org.apache.deltaspike.data.api.Query.class)) {
  3. return method.getAnnotation(org.apache.deltaspike.data.api.Query.class).max();
  4. }
  5. return repositoryMethod.getDefinedMaxResults();
  6. }

相关文章