spring-data

No property index found for type User

拟墨画扇 提交于 2021-01-27 06:03:40
问题 I'm trying to use ElasticSearch with MySQL in the same project. I defined two repositories in different project but I always get this error message: Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userController': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.owish.services.UserServices com.owish.controllers

Spring Data Elasticsearch (4.x) - Using @Id forces id field in _source

旧时模样 提交于 2021-01-27 05:19:12
问题 Summary Recently we upgraded to Spring Data Elasticsearch 4.x. Part of this major release meant that Jackson is no longer used to convert our domain objects to json (using MappingElasticsearchConverter instead) [1]. This means we are now forced to add a new id field to all our documents. Previously we had domain objects like this: import org.springframework.data.annotation.Id; public ESDocument { @Id private String id; private String field1; @JsonIgnore public String getId() { return id; }

Spring Data Elasticsearch (4.x) - Using @Id forces id field in _source

蓝咒 提交于 2021-01-27 05:19:08
问题 Summary Recently we upgraded to Spring Data Elasticsearch 4.x. Part of this major release meant that Jackson is no longer used to convert our domain objects to json (using MappingElasticsearchConverter instead) [1]. This means we are now forced to add a new id field to all our documents. Previously we had domain objects like this: import org.springframework.data.annotation.Id; public ESDocument { @Id private String id; private String field1; @JsonIgnore public String getId() { return id; }

Spring Data Elasticsearch (4.x) - Using @Id forces id field in _source

人走茶凉 提交于 2021-01-27 05:18:21
问题 Summary Recently we upgraded to Spring Data Elasticsearch 4.x. Part of this major release meant that Jackson is no longer used to convert our domain objects to json (using MappingElasticsearchConverter instead) [1]. This means we are now forced to add a new id field to all our documents. Previously we had domain objects like this: import org.springframework.data.annotation.Id; public ESDocument { @Id private String id; private String field1; @JsonIgnore public String getId() { return id; }

Returning both old and new entities from Spring/MongoDB findAndModify

穿精又带淫゛_ 提交于 2021-01-26 07:15:20
问题 We're using MongoDB via Spring Data and rely on the findAndModify operation to update existing entities or create new ones. In the findAndModify we can configure to return old state of the entity or the new one using returnNew(...) . Is there some way to return both old and new entities from findAndModify ? We need to compare entity states before and after update, this is why we need both instances. At the moment we're resorting to requireNew(false) and then manually update a copy of the old

Spring Boot setting up MongoDB repository

亡梦爱人 提交于 2021-01-23 06:51:08
问题 I am trying to setup MongoDB repository for CRUD operation in my spring-boot rest app. Here is what i have so far My applicaiton.yml file server: data: mongodb: localhost port: 27017 database: dbname My DbConfiguration class @Configuration @EnableMongoRepositories("com.package.path.to.repository") @Import(value = MongoAutoConfiguration.class) public class DbConfiguration extends AbstractMongoConfiguration { private final Logger log = LoggerFactory.getLogger(DbConfiguration.class); @Autowired

Spring Data: JPA repository findAll() to return *Map instead of List?

与世无争的帅哥 提交于 2021-01-21 13:19:28
问题 I have a Spring Data JPA repository interface that looks something like this: @Repository public interface DBReportRepository extends JpaRepository<TransactionModel, Long> { List<TransactionModel> findAll(); List<TransactionModel> findByClientId(Long id); } Is there a workaround to make the same but for a Collection to be returned of type HashMap<K, V> ? I've looked through the Spring Data classes and couldn't find anything other than List<> return values. 回答1: I dont think you will find an

how to unit test method using “Spring Data JPA” Specifications

廉价感情. 提交于 2021-01-21 06:52:45
问题 I was playing with org.springframework.data.jpa.domain.Specifications, it's just a basic search : public Optional<List<Article>> rechercheArticle(String code, String libelle) { List<Article> result = null; if(StringUtils.isNotEmpty(code) && StringUtils.isNotEmpty(libelle)){ result = articleRepository.findAll(Specifications.where(ArticleSpecifications.egaliteCode(code)).and(ArticleSpecifications.egaliteLibelle(libelle))); }else{ if(StringUtils.isNotEmpty(code)){ result= articleRepository

how to unit test method using “Spring Data JPA” Specifications

血红的双手。 提交于 2021-01-21 06:52:06
问题 I was playing with org.springframework.data.jpa.domain.Specifications, it's just a basic search : public Optional<List<Article>> rechercheArticle(String code, String libelle) { List<Article> result = null; if(StringUtils.isNotEmpty(code) && StringUtils.isNotEmpty(libelle)){ result = articleRepository.findAll(Specifications.where(ArticleSpecifications.egaliteCode(code)).and(ArticleSpecifications.egaliteLibelle(libelle))); }else{ if(StringUtils.isNotEmpty(code)){ result= articleRepository

Spring Data Rest: “Date is null” query throws an postgres exception

笑着哭i 提交于 2021-01-21 06:37:08
问题 I use Spring Boot and Data Rest to create a simple microservice in Java8 and get a postgres exception. My entity: @Entity public class ArchivedInvoice implements Serializable { ... @Column private String invoiceNumber; @Column private java.sql.Date invoiceDate; ... } My repository interface: @RepositoryRestResource(collectionResourceRel = "archivedinvoices", path = "archivedinvoices") public interface ArchivedInvoiceRepository extends PagingAndSortingRepository < ArchivedInvoice, Long > { ...