spring-data

Spring JPA :: No converter found capable of converting from type

余生长醉 提交于 2020-12-28 06:43:25
问题 I am using spring with JPA and trying to execute query using @query with SQL query.and trying to map the result to an object. I have different entity class and mapping to other dto as I do not want all the columns. getting below error No converter found capable of converting from type [org.springframework.data.jpa.repository.query.AbstractJpaQuery$TupleConverter$TupleBackedMap] to type [webapi.dto.StatsDTO]", Below is my repository interface public interface UserRepository extends

Spring JPA :: No converter found capable of converting from type

心不动则不痛 提交于 2020-12-28 06:42:44
问题 I am using spring with JPA and trying to execute query using @query with SQL query.and trying to map the result to an object. I have different entity class and mapping to other dto as I do not want all the columns. getting below error No converter found capable of converting from type [org.springframework.data.jpa.repository.query.AbstractJpaQuery$TupleConverter$TupleBackedMap] to type [webapi.dto.StatsDTO]", Below is my repository interface public interface UserRepository extends

Spring data query for localdate returns wrong entries - minus one day

余生长醉 提交于 2020-12-13 04:52:09
问题 In my Entity i have a field of type LocalDate "day" in MySQL it is mapped to "date" type. MySQL seems to run on UTC SELECT TIMEDIFF(NOW(), UTC_TIMESTAMP); is returning 00:00:00 . My system is running CET (UTC+1) If i query it via sql (console from IntelliJ configured with empty Time zone ) the query select * from table where day = '2020-10-18'; Returns entries with correct date. The query specified with Spring data findByDay is also looking correct: 2020-11-09 16:16:32.911 DEBUG 5600 --- [

Spring webflux ReactiveMongoOperations find by elemMatch

天涯浪子 提交于 2020-12-13 04:41:08
问题 I have a collection like this: {"type": "bbb", "category": "aaa", "from": "eee", "INTERLOCUTOR": ["test1", "test2"]} and I want to find INTERLOCUTOR have test1 ; how to use by ReactiveMongoOperations ? 回答1: db.collection.find({"INTERLOCUTOR" : "test1"}) 回答2: Using ReactiveMongoOperations and processing the returned reactor.core.publisher.Flux to print the query returned documents: ReactiveMongoOperations ops = new ReactiveMongoTemplate(MongoClients.create(), "test"); Criteria c = Criteria

MongoRepository query for between dates

断了今生、忘了曾经 提交于 2020-12-08 06:28:14
问题 My pojo public class PacketData implements Serializable { private static final long serialVersionUID = 1L; @Id private final String token = UUID.randomUUID().toString(); private final ZonedDateTime arrived = ZonedDateTime.now(); } I plan to use like following. @Query("?") List<PacketData> findPacketArrivedBetween(ZonedDateTime startDate, ZonedDateTime endDate); Is there a way i can put the following query to the above query annotation and how i can do greater than and less than logic Query

MongoRepository query for between dates

怎甘沉沦 提交于 2020-12-08 06:28:08
问题 My pojo public class PacketData implements Serializable { private static final long serialVersionUID = 1L; @Id private final String token = UUID.randomUUID().toString(); private final ZonedDateTime arrived = ZonedDateTime.now(); } I plan to use like following. @Query("?") List<PacketData> findPacketArrivedBetween(ZonedDateTime startDate, ZonedDateTime endDate); Is there a way i can put the following query to the above query annotation and how i can do greater than and less than logic Query

Same query method and parameters with different return in Spring Data

你。 提交于 2020-12-06 06:37:52
问题 I want to use projections in order to return less elements for the same queries. Page<Network> findByIdIn(List<Long> ids); Page<NetworkSimple> findByIdIn(List<Long> ids); Since the queries are created using the name of the method, what options do I have to do the same query but with different name ? 回答1: Spring Data query via method is constructed by convention and you can't change the name and yet expecting a same behavior. You can try to use @Query annotations which doesn't depend on the

Same query method and parameters with different return in Spring Data

五迷三道 提交于 2020-12-06 06:34:26
问题 I want to use projections in order to return less elements for the same queries. Page<Network> findByIdIn(List<Long> ids); Page<NetworkSimple> findByIdIn(List<Long> ids); Since the queries are created using the name of the method, what options do I have to do the same query but with different name ? 回答1: Spring Data query via method is constructed by convention and you can't change the name and yet expecting a same behavior. You can try to use @Query annotations which doesn't depend on the

JPA Query Returning Same Result for different Parameter

偶尔善良 提交于 2020-12-05 11:58:29
问题 I'm running into an issue where my query method is in a foreach loop, and each time I'm passing in a different parameter to retrieve different information. However, after the FIRST iteration of the loop, the query data gets cached (I think) and returns the same data for subsequent loops. Here is my code: @Transactional(readOnly = true) public List<InitiativeReport> getInitiativeReports() throws Exception { try { List<InitiativeReport> ir = new ArrayList<InitiativeReport>(); List<Initiative>

How to make Spring server to start even if database is down?

青春壹個敷衍的年華 提交于 2020-12-01 00:34:40
问题 I'm using a Spring Boot(1.4.7) & MyBatis. spring.main1.datasource.url=jdbc:mariadb://192.168.0.11:3306/testdb?useUnicode=true&characterEncoding=utf8&autoReconnect=true&socketTimeout=5000&connectTimeout=3000 spring.main1.datasource.username=username spring.main1.datasource.password=password spring.main1.datasource.driverClassName=org.mariadb.jdbc.Driver spring.main1.datasource.tomcat.test-on-borrow=true spring.main1.datasource.tomcat.test-while-idle=true spring.main1.datasource.tomcat