• <i id='SG7Ea'><tr id='SG7Ea'><dt id='SG7Ea'><q id='SG7Ea'><span id='SG7Ea'><b id='SG7Ea'><form id='SG7Ea'><ins id='SG7Ea'></ins><ul id='SG7Ea'></ul><sub id='SG7Ea'></sub></form><legend id='SG7Ea'></legend><bdo id='SG7Ea'><pre id='SG7Ea'><center id='SG7Ea'></center></pre></bdo></b><th id='SG7Ea'></th></span></q></dt></tr></i><div id='SG7Ea'><tfoot id='SG7Ea'></tfoot><dl id='SG7Ea'><fieldset id='SG7Ea'></fieldset></dl></div>
  • <legend id='SG7Ea'><style id='SG7Ea'><dir id='SG7Ea'><q id='SG7Ea'></q></dir></style></legend>

    • <bdo id='SG7Ea'></bdo><ul id='SG7Ea'></ul>

      1. <tfoot id='SG7Ea'></tfoot>

        <small id='SG7Ea'></small><noframes id='SG7Ea'>

        “没有找到类型的属性"......当将 QueryDslPredicateExecutor 与 MongoDB

        quot;No property exists found for typequot;... When using the QueryDslPredicateExecutor with MongoDB and Spring-Data(“没有找到类型的属性......当将 QueryDslPredicateExecutor 与 MongoDB 和 Spring-Data 一起使用时) - IT屋-程序员软件开发技术分
          <tbody id='6zaJk'></tbody>
            <bdo id='6zaJk'></bdo><ul id='6zaJk'></ul>
              <legend id='6zaJk'><style id='6zaJk'><dir id='6zaJk'><q id='6zaJk'></q></dir></style></legend>
            1. <small id='6zaJk'></small><noframes id='6zaJk'>

                • <i id='6zaJk'><tr id='6zaJk'><dt id='6zaJk'><q id='6zaJk'><span id='6zaJk'><b id='6zaJk'><form id='6zaJk'><ins id='6zaJk'></ins><ul id='6zaJk'></ul><sub id='6zaJk'></sub></form><legend id='6zaJk'></legend><bdo id='6zaJk'><pre id='6zaJk'><center id='6zaJk'></center></pre></bdo></b><th id='6zaJk'></th></span></q></dt></tr></i><div id='6zaJk'><tfoot id='6zaJk'></tfoot><dl id='6zaJk'><fieldset id='6zaJk'></fieldset></dl></div>

                  <tfoot id='6zaJk'></tfoot>

                • 本文介绍了“没有找到类型的属性"......当将 QueryDslPredicateExecutor 与 MongoDB 和 Spring-Data 一起使用时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在尝试将 QueryDslPredicateExecutor 与 MongoDB 和 Spring-Data 一起使用,但它似乎对exists()"属性感到窒息.

                  I'm trying to use the QueryDslPredicateExecutor with MongoDB and Spring-Data, but it seems to be choking on the "exists()" property.

                  我正在使用 -

                  org.springframework.boot:spring-boot-starter-parent:1.3.5.RELEASE  
                  com.querydsl:querydsl-mongodb:4.1.2  
                  com.querydsl:querydsl-apt:4.1.2  
                  org.mongodb.morphia:morphia:1.1.1  
                  

                  堆栈跟踪

                  Caused by: org.springframework.data.mapping.PropertyReferenceException: No property exists found for type Tree!
                      at org.springframework.data.mapping.PropertyPath.<init>(PropertyPath.java:77) ~[spring-data-commons-1.12.0.RELEASE.jar:na]
                      at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:329) ~[spring-data-commons-1.12.0.RELEASE.jar:na]
                      at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:309) ~[spring-data-commons-1.12.0.RELEASE.jar:na]
                      at org.springframework.data.mapping.PropertyPath.from(PropertyPath.java:272) ~[spring-data-commons-1.12.0.RELEASE.jar:na]
                      at org.springframework.data.mapping.PropertyPath.from(PropertyPath.java:243) ~[spring-data-commons-1.12.0.RELEASE.jar:na]
                      at org.springframework.data.repository.query.parser.Part.<init>(Part.java:76) ~[spring-data-commons-1.12.0.RELEASE.jar:na]
                      at org.springframework.data.repository.query.parser.PartTree$OrPart.<init>(PartTree.java:235) ~[spring-data-commons-1.12.0.RELEASE.jar:na]
                      at org.springframework.data.repository.query.parser.PartTree$Predicate.buildTree(PartTree.java:373) ~[spring-data-commons-1.12.0.RELEASE.jar:na]
                      at org.springframework.data.repository.query.parser.PartTree$Predicate.<init>(PartTree.java:353) ~[spring-data-commons-1.12.0.RELEASE.jar:na]
                      at org.springframework.data.repository.query.parser.PartTree.<init>(PartTree.java:84) ~[spring-data-commons-1.12.0.RELEASE.jar:na]
                      at org.springframework.data.mongodb.repository.query.PartTreeMongoQuery.<init>(PartTreeMongoQuery.java:60) ~[spring-data-mongodb-1.9.0.RELEASE.jar:na]
                      at org.springframework.data.mongodb.repository.support.MongoRepositoryFactory$MongoQueryLookupStrategy.resolveQuery(MongoRepositoryFactory.java:168) ~[spring-data-mongodb-1.9.0.RELEASE.jar:na]
                      at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.<init>(RepositoryFactorySupport.java:435) ~[spring-data-commons-1.12.0.RELEASE.jar:na]
                      at org.springframework.data.repository.core.support.RepositoryFactorySupport.getRepository(RepositoryFactorySupport.java:220) ~[spring-data-commons-1.12.0.RELEASE.jar:na]
                      at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.initAndReturn(RepositoryFactoryBeanSupport.java:266) ~[spring-data-commons-1.12.0.RELEASE.jar:na]
                      at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.afterPropertiesSet(RepositoryFactoryBeanSupport.java:252) ~[spring-data-commons-1.12.0.RELEASE.jar:na]
                      at org.springframework.data.mongodb.repository.support.MongoRepositoryFactoryBean.afterPropertiesSet(MongoRepositoryFactoryBean.java:108) ~[spring-data-mongodb-1.9.0.RELEASE.jar:na]
                      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1637) ~[spring-beans-4.2.6.RELEASE.jar:4.2.6.RELEASE]
                      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1574) ~[spring-beans-4.2.6.RELEASE.jar:4.2.6.RELEASE]
                      ... 30 common frames omitted
                  

                  这个类正在抛出异常

                  package org.springframework.data.mapping
                  // PropertyPath.class 
                  ....
                  
                  /**
                   * Creates a leaf {@link PropertyPath} (no nested ones with the given name and owning type.
                   * 
                   * @param name must not be {@literal null} or empty.
                   * @param owningType must not be {@literal null}.
                   * @param base the {@link PropertyPath} previously found.
                   */
                  PropertyPath(String name, TypeInformation<?> owningType, List<PropertyPath> base) {
                  
                      Assert.hasText(name, "Name must not be null or empty!");
                      Assert.notNull(owningType, "Owning type must not be null!");
                      Assert.notNull(base, "Perviously found properties must not be null!");
                  
                      String propertyName = name.matches(ALL_UPPERCASE) ? name : StringUtils.uncapitalize(name);
                      TypeInformation<?> propertyType = owningType.getProperty(propertyName);
                  
                      if (propertyType == null) {
                          throw new PropertyReferenceException(propertyName, owningType, base);
                      }
                  
                      this.owningType = owningType;
                      this.isCollection = propertyType.isCollectionLike();
                      this.type = propertyType.getActualType();
                      this.name = propertyName;
                  }
                  

                  属性(方法)来自我的存储库扩展的 QueryDslPredicateExecutor 类.

                  The property (method) is coming from the QueryDslPredicateExecutor class that my Repository extends.

                  public abstract boolean org.springframework.data.querydsl.QueryDslPredicateExecutor.exists(com.querydsl.core.types.Predicate)  
                  

                  这里是存储库-

                  public interface TreeRepository extends ExtendedMongoRepository<Tree, String>, QueryDslPredicateExecutor<Tree>{}
                  

                  推荐答案

                  我最终通过扩展和实现 QueryDslPredicateExecutor 而不是更高级别的存储库来解决这个问题.

                  I ended up solving this by having my base repository extend and implement the QueryDslPredicateExecutor, rather than the higher level repository.

                  // Custom repository interface
                  @NoRepositoryBean
                  public interface ExtendedMongoRepository<T, ID extends Serializable> extends MongoRepository<T, ID>, QueryDslPredicateExecutor<T>{
                  
                    public Page<T> query(Query query, Pageable pageable);
                  
                  }
                  
                  
                  // Custom Repository Implementation
                  public abstract class ExtendedMongoRepositoryImpl<T, ID extends Serializable> extends QueryDslMongoRepository<T, ID>
                          implements ExtendedMongoRepository<T, ID> {
                  
                      private Class<T> clazz;
                      private MongoOperations mongoOperations;
                      @SuppressWarnings("unused")
                      private MongoEntityInformation<T, ID> metadata;
                  
                      public ExtendedMongoRepositoryImpl(MongoEntityInformation<T, ID> metadata, MongoOperations mongoOperations) {
                          super(metadata, mongoOperations);
                          this.mongoOperations = mongoOperations;
                          this.clazz = metadata.getJavaType();
                          this.metadata = metadata;
                      }
                  
                      @Override
                      public Page<T> query(Query query, Pageable pageable) {
                          List<T> list =  mongoOperations.find(query.with(pageable), clazz);
                          return new PageImpl<T>(list, pageable, list.size());
                      }
                  }  
                  
                  // Entity Repository Interface
                  public interface TreeRepository extends ExtendedMongoRepository<Tree, String> {}
                  

                  这篇关于“没有找到类型的属性"......当将 QueryDslPredicateExecutor 与 MongoDB 和 Spring-Data 一起使用时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  How to send data to COM PORT using JAVA?(如何使用 JAVA 向 COM PORT 发送数据?)
                  How to make a report page direction to change to quot;rtlquot;?(如何使报表页面方向更改为“rtl?)
                  Use cyrillic .properties file in eclipse project(在 Eclipse 项目中使用西里尔文 .properties 文件)
                  Is there any way to detect an RTL language in Java?(有没有办法在 Java 中检测 RTL 语言?)
                  How to load resource bundle messages from DB in Java?(如何在 Java 中从 DB 加载资源包消息?)
                  How do I change the default locale settings in Java to make them consistent?(如何更改 Java 中的默认语言环境设置以使其保持一致?)
                    <tbody id='g7gTa'></tbody>
                  <legend id='g7gTa'><style id='g7gTa'><dir id='g7gTa'><q id='g7gTa'></q></dir></style></legend>

                  <small id='g7gTa'></small><noframes id='g7gTa'>

                    <tfoot id='g7gTa'></tfoot>

                          <bdo id='g7gTa'></bdo><ul id='g7gTa'></ul>
                            <i id='g7gTa'><tr id='g7gTa'><dt id='g7gTa'><q id='g7gTa'><span id='g7gTa'><b id='g7gTa'><form id='g7gTa'><ins id='g7gTa'></ins><ul id='g7gTa'></ul><sub id='g7gTa'></sub></form><legend id='g7gTa'></legend><bdo id='g7gTa'><pre id='g7gTa'><center id='g7gTa'></center></pre></bdo></b><th id='g7gTa'></th></span></q></dt></tr></i><div id='g7gTa'><tfoot id='g7gTa'></tfoot><dl id='g7gTa'><fieldset id='g7gTa'></fieldset></dl></div>