spring-data

Spring MongoDB Data elemMatch Simple

萝らか妹 提交于 2020-04-11 06:15:10
问题 { _id: 1, results: [ "tokyo", "japan" ] } { _id: 2, results: [ "sydney", "australia" ] } db.scores.find( { results: { $elemMatch: { $regex: *some regex* } } } ) How do you convert this simple elemMatch example using spring mongodb data Query Criteria? If the array contains object I can do it this way Criteria criteria = Criteria.where("results"). elemMatch( Criteria.where("field").is("tokyo") ); But in my question, I dont have the "field" Update: I thought the Veeram's answer was going to

Failed to load driver class org.mariadb.jdbc.Driver

若如初见. 提交于 2020-04-10 14:46:31
问题 I want to configure 2 JNDI datasources in Spring Boot. I tried this configuration: application.properties spring.production-datasource.jndi-name=java:/global/production_gateway spring.production-datasource.driver-class-name=org.mariadb.jdbc.Driver spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MariaDBDialect spring.jpa.show-sql = true spring.jpa.hibernate.ddl-auto = update spring.warehouse-datasource.jndi-name=java:/global/production_warehouse spring.warehouse-datasource.driver

Failed to load driver class org.mariadb.jdbc.Driver

你离开我真会死。 提交于 2020-04-10 14:46:22
问题 I want to configure 2 JNDI datasources in Spring Boot. I tried this configuration: application.properties spring.production-datasource.jndi-name=java:/global/production_gateway spring.production-datasource.driver-class-name=org.mariadb.jdbc.Driver spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MariaDBDialect spring.jpa.show-sql = true spring.jpa.hibernate.ddl-auto = update spring.warehouse-datasource.jndi-name=java:/global/production_warehouse spring.warehouse-datasource.driver

Atomic increment with Spring Data for AWS ElastiCache (Redis)

不问归期 提交于 2020-03-25 19:16:07
问题 We have multiple instances of the same application deployed behind an ELB (Load Balancer). Whenever a certain job is done, we count some elements and then want to increment a counter's value. We use ElastiCache to hold these metrics in memory. We have set it up as a Cluster of Redis instances. I'm having trouble understanding how to properly interact with ElastiCache so that the counter never misses any increment (i.e. an atomic operation). I know INCRBY seems to be the way to go, but I'm not

Spring Data JDBC SQLFeatureNotSupportedException while saving list of enum to MySql

时间秒杀一切 提交于 2020-03-23 08:06:42
问题 I've a model named Role . A role has a list of Permission s, simple as that. Using org.springframework.boot:2.2.5.RELEASE, spring-jdbc version 5.2.24, mysql-connector-java-8.0.19, mysql server version 5.7.28 You can also checkout https://github.com/tirbison/spring-data-jdbc-kotlin/tree/bug/mysql-list-of-enum to reproduce the bug, do not forget to change the mysql credentials. Role.kt package com.example.demo.domain.model import org.springframework.data.annotation.Id class Role( val name:

Spring Data JDBC SQLFeatureNotSupportedException while saving list of enum to MySql

…衆ロ難τιáo~ 提交于 2020-03-23 08:06:03
问题 I've a model named Role . A role has a list of Permission s, simple as that. Using org.springframework.boot:2.2.5.RELEASE, spring-jdbc version 5.2.24, mysql-connector-java-8.0.19, mysql server version 5.7.28 You can also checkout https://github.com/tirbison/spring-data-jdbc-kotlin/tree/bug/mysql-list-of-enum to reproduce the bug, do not forget to change the mysql credentials. Role.kt package com.example.demo.domain.model import org.springframework.data.annotation.Id class Role( val name:

Spring Data: Not an managed type: class java.lang.Object

徘徊边缘 提交于 2020-03-21 23:09:11
问题 I am trying to expose my db tables via spring boot by following different spring tutorials and I am running into following exception (I will post exception at the end). Here are the classes that I am using package com.xxx.xxx.db; import org.springframework.data.repository.Repository; import java.io.Serializable; public interface BaseRepository<T, ID extends Serializable> extends Repository<T, ID>{ T findOne(ID id); T save(T entity); } And here is my specific service class package com.xxx.xxx

Spring Data CrudRepository @Query With LIKE and IgnoreCase

懵懂的女人 提交于 2020-03-19 05:01:07
问题 I need to retrieve some Entity fields from CrudRepository: public class User { private String name; // getters and setters } public interface UserRepository extends CrudRepository<User, Long> { @Query("SELECT U.name FROM User U WHERE LOWER(U.name) LIKE LOWER(?1)") List<String> findByName(String matchPhrase); } Basically, I want to get equivalent of SQL query: SELECT u.name FROM user u WHERE LOWER(u.name) LIKE LOWER('match%') The problem is that @Query doesn't works (empty list returned),

Problems to inject Repository when data-jpa dep is on

℡╲_俬逩灬. 提交于 2020-03-03 08:41:21
问题 I noticed, as soon as I un-comment JPA dep, see below: implementation("org.springframework.boot:spring-boot-starter-jdbc") implementation ("org.springframework.boot:spring-boot-starter-data-jdbc") //implementation ("org.springframework.boot:spring-boot-starter-data-jpa") I do not have any @Entity annotated classes in my code. I got an error on start: The bean 'myRepository', defined in null, could not be registered. A bean with that name has already been defined in null and overriding is

Problems to inject Repository when data-jpa dep is on

故事扮演 提交于 2020-03-03 08:41:07
问题 I noticed, as soon as I un-comment JPA dep, see below: implementation("org.springframework.boot:spring-boot-starter-jdbc") implementation ("org.springframework.boot:spring-boot-starter-data-jdbc") //implementation ("org.springframework.boot:spring-boot-starter-data-jpa") I do not have any @Entity annotated classes in my code. I got an error on start: The bean 'myRepository', defined in null, could not be registered. A bean with that name has already been defined in null and overriding is