java找不到Query_java – “找不到类型的属性”…使用QueryDslPredicateExecutor与MongoDB和Spring-Data...

我正在尝试将QueryDslPredicateExecutor与MongoDB和

Spring-Data一起使用,但它似乎在“exists()”属性上窒息.

我正在使用 –

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.(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.(Part.java:76) ~[spring-data-commons-1.12.0.RELEASE.jar:na]

at org.springframework.data.repository.query.parser.PartTree$OrPart.(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.(PartTree.java:353) ~[spring-data-commons-1.12.0.RELEASE.jar:na]

at org.springframework.data.repository.query.parser.PartTree.(PartTree.java:84) ~[spring-data-commons-1.12.0.RELEASE.jar:na]

at org.springframework.data.mongodb.repository.query.PartTreeMongoQuery.(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.(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 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;

}

属性(方法)来自我的Repository扩展的QueryDslPredicateExecutor类.

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

这是存储库 –

public interface TreeRepository extends ExtendedMongoRepository, QueryDslPredicateExecutor{}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值