Spring Boot,JPA和Ignite
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Spring Boot,JPA和Ignite相关的知识,希望对你有一定的参考价值。
引起:org.springframework.data.mapping.PropertyReferenceException:找不到类型Person的属性保存!
实体 :
@Entity
public class Person implements Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue
@QuerySqlField(index = true)
public Long id;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
}
@Component
@RepositoryConfig(cacheName = "PersonCache")
@Repository
public interface PersonRepository extends IgniteRepository<Person, Long> {
@Override
List<Person> findAll();
@Override
Person findOne(Long id);
}
点燃配置:
@Bean
public Ignite igniteInstance() {
IgniteConfiguration cfg = new IgniteConfiguration();
// Setting some custom name for the node.
cfg.setIgniteInstanceName("springDataNode");
// Enabling peer-class loading feature.
cfg.setPeerClassLoadingEnabled(true);
// Defining and creating a new cache to be used by Ignite Spring Data repository.
CacheConfiguration ccfg = new CacheConfiguration("PersonCache");
// Setting SQL schema for the cache.
ccfg.setIndexedTypes(Long.class, Person.class);
cfg.setCacheConfiguration(ccfg);
return Ignition.start(cfg);
}
堆栈跟踪:
引起:org.springframework.data.mapping.PropertyReferenceException:找不到类型Person的属性保存! at org.springframework.data.mapping.PropertyPath。(PropertyPath.java:77)〜[spring-data-commons-1.13.1.RELEASE.jar:na] at org.springframework.data.mapping.PropertyPath.create(PropertyPath .java:329)〜[spring-data-commons-1.13.1.RELEASE.jar:na] org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:309)〜[spring-data-commons- 1.13.1.RELEASE.jar:na] at org.springframework.data.mapping.PropertyPath.from(PropertyPath.java:272)〜[spring-data-commons-1.13.1.RELEASE.jar:na] at org。 springframework.data.mapping.PropertyPath.from(PropertyPath.java:243)〜[spring-data-commons-1.13.1.RELEASE.jar:na] at org.springframework.data.repository.query.parser.Part。( Part.java:76)〜[spring-data-commons-1.13.1.RELEASE.jar:na] at org.springframework.data.repository.query.parser.PartTree $ OrPart。(PartTree.java:247)〜[ spring-data-commons-1.13.1.RELEASE.jar:na] at org.springframework.data.repository.query.parser.PartTree $ Predicate.buildTree(PartTree.java:398)〜[spring-data-commons-1.13 .1.RELEASE.jar: na] org.springframework.data.repository.query.parser.PartTree $ Predicate。(PartTree.java:378)〜[spring-data-commons-1.13.1.RELEASE.jar:na] at org.springframework.data .repository.query.parser.PartTree。(PartTree.java:86)〜[spring-data-commons-1.13.1.RELEASE.jar:na] at org.springframework.data.jpa.repository.query.PartTreeJpaQuery。( PartTreeJpaQuery.java:64)〜[spring-data-jpa-1.11.3.RELEASE.jar:na] at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy $ CreateQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:103)~ [spring-data-jpa-1.11.3.RELEASE.jar:na] at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy $ CreateIfNotFoundQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:214)〜[spring-data-jpa- 1.11.3.RELEASE.jar:na] at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy $ AbstractQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:77)〜[spring-data-jpa-1.11.3.RELEASE.jar :na] at org.springframework.data.reposit ory.core.support.RepositoryFactorySupport $ QueryExecutorMethodInterceptor。(RepositoryFactorySupport.java:436)〜[spring-data-commons-1.13.1.RELEASE.jar:na] at org.springframework.data.repository.core.support.RepositoryFactorySupport。在org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.initAndReturn(RepositoryFactoryBeanSupport.java:277)的getRepository(RepositoryFactorySupport.java:221)〜[spring-data-commons-1.13.1.RELEASE.jar:na]〜 [spring-data-commons-1.13.1.RELEASE.jar:na] at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.afterPropertiesSet(RepositoryFactoryBeanSupport.java:263)~ [spring-data-commons-1.13。 1.RELEASE.jar:na] at org.springframework.data.jpa.repository.support.JpaRepositoryFactoryBean.afterPropertiesSet(JpaRepositoryFactoryBean.java:101)〜[spring-data-jpa-1.11.3.RELEASE.jar:na] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:168 7)〜[spring-beans-4.3.8.RELEASE.jar:4.3.8.RELEASE] org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1624)~ [spring-beans-4.3 .8.RELEASE.jar:4.3.8.RELEASE] ...省略了16个常用帧
您似乎正在尝试使用IgniteRepository来处理JPA实体。
我认为不可能将这两者结合起来。 Spring JPA会阻止IgniteRepository自定义方法尝试将它们转换为SQL,即使它没有,它仍然无法正常工作。
IgniteRepository只是不是为JPA设计的。
以上是关于Spring Boot,JPA和Ignite的主要内容,如果未能解决你的问题,请参考以下文章
Spring Boot:在Spring Boot中使用Mysql和JPA
使用 spring-data-jpa 和 MockMvc 进行 spring boot junit 测试
Spring Boot (十五): Spring Boot + Jpa + Thymeleaf 增删改查示例
spring boot系列spring boot 配置spring data jpa (查询方法)