spring-data-jpa

merge separate queries into one query

家住魔仙堡 提交于 2021-01-07 06:51:08
问题 i have the following query using boolQueryBuilder which check if status1 or status2 AND the time is less than currentTime is matchs : public BoolQueryBuilder createSearchQuery(Long currentTime) { // Build and operator final BoolQueryBuilder firstAndOperator = createAndOperator(currentTime, "status1"); // Build AND operator final BoolQueryBuilder secondAndOperator = createAndOperator(currentTime, "status2); // Build OR return createOrOperator(firstAndOperator, secondAndOperator); } private

Spring boot application is not starting

蹲街弑〆低调 提交于 2021-01-07 02:51:18
问题 My spring boot application is not able to start. I am unable to find the root cause of that. I guess Hikari pool may create the issue for that. Below is the log. Any help will be appreciated. {"timestamp": "12/22/2020 14:48:58:0354", "class": "com.zaxxer.hikari.pool.HikariPool$PoolEntryCreator", "file": "HikariPool.java", "level" : "DEBUG", "line_number" : "728", "url": "", "ip_address": "", "server_trace_id":"", "message": HikariPool-1 - Added connection org.postgresql.jdbc.PgConnection

Spring boot application is not starting

ε祈祈猫儿з 提交于 2021-01-07 02:50:04
问题 My spring boot application is not able to start. I am unable to find the root cause of that. I guess Hikari pool may create the issue for that. Below is the log. Any help will be appreciated. {"timestamp": "12/22/2020 14:48:58:0354", "class": "com.zaxxer.hikari.pool.HikariPool$PoolEntryCreator", "file": "HikariPool.java", "level" : "DEBUG", "line_number" : "728", "url": "", "ip_address": "", "server_trace_id":"", "message": HikariPool-1 - Added connection org.postgresql.jdbc.PgConnection

@Query doesn't work in Spring Boot (JPA ) + Azure Cosmos db

◇◆丶佛笑我妖孽 提交于 2021-01-06 07:54:07
问题 I'm developing some IoT application. Data is in Azure Cosmos DB. example) { "id": "3ebd07c0-0740-466f-acb4-1e04a58cdf1a", "serviceId": 1, "deviceId": 1, "contents": "{\"temperature\":34.797642257199705,\"humidity\":79.18982439419167,\"illuminance\":100}", "date": 1552376519931 } So. I want to use custom query like this public interface DeviceTelemetryRepository extends DocumentDbRepository<DeviceTelemetry, String> { @Query("SELECT a.deviceId FROM device_telemetry a where a.deviceId=:deviceId

@Query doesn't work in Spring Boot (JPA ) + Azure Cosmos db

ⅰ亾dé卋堺 提交于 2021-01-06 07:48:05
问题 I'm developing some IoT application. Data is in Azure Cosmos DB. example) { "id": "3ebd07c0-0740-466f-acb4-1e04a58cdf1a", "serviceId": 1, "deviceId": 1, "contents": "{\"temperature\":34.797642257199705,\"humidity\":79.18982439419167,\"illuminance\":100}", "date": 1552376519931 } So. I want to use custom query like this public interface DeviceTelemetryRepository extends DocumentDbRepository<DeviceTelemetry, String> { @Query("SELECT a.deviceId FROM device_telemetry a where a.deviceId=:deviceId

How to save timestamp in UTC format for Audit fields @CreatedDate, @LastModifiedDate in Spring JPA

大憨熊 提交于 2021-01-05 12:26:52
问题 This is my Base Class for Entities with audit fields. For fields @CreatedDate, @LastModifiedDate, by default it is saving my system time. My requirement is to save timestamp in UTC. Does anyone have a solution of this? import java.time.LocalDateTime; import javax.persistence.Column; import javax.persistence.EntityListeners; import javax.persistence.MappedSuperclass; import org.springframework.data.annotation.CreatedBy; import org.springframework.data.annotation.CreatedDate; import org

Why is hibernate trying to find an entity in the database instead of creating it? [closed]

风流意气都作罢 提交于 2021-01-05 07:21:22
问题 Closed. This question needs debugging details. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 8 days ago . Improve this question I have two entities. @Entity public class Parent { @Id private UUID id; private String someValue; @OneToOne(cascade = CascadeType.PERSIST) @JoinColumn(name = "child_id", referencedColumnName = "id") private Child child; } @Entity public class Child { @Id @GeneratedValue private

@ResponseBody returns empty object

拈花ヽ惹草 提交于 2021-01-05 00:58:45
问题 When I use below to get the user object it works just fine. @GetMapping("/findOne") @ResponseBody public Optional<AppUser> findOne (Long id) { return appUserRepository.findById(id); } Above gives me a response back as: {"id":1,"useruuid":"863db606-9af6-48a8-963a-07b9fe0fc4fc","useremail":"user1@mydomain.com"} Now, I am trying to search based on UUID(4) using this: @GetMapping("/findOneUsingUUID") @ResponseBody public AppUser findOne (String useruuid) { return appUserRepository.findByUseruuid

@ResponseBody returns empty object

久未见 提交于 2021-01-05 00:53:10
问题 When I use below to get the user object it works just fine. @GetMapping("/findOne") @ResponseBody public Optional<AppUser> findOne (Long id) { return appUserRepository.findById(id); } Above gives me a response back as: {"id":1,"useruuid":"863db606-9af6-48a8-963a-07b9fe0fc4fc","useremail":"user1@mydomain.com"} Now, I am trying to search based on UUID(4) using this: @GetMapping("/findOneUsingUUID") @ResponseBody public AppUser findOne (String useruuid) { return appUserRepository.findByUseruuid

@ResponseBody returns empty object

人盡茶涼 提交于 2021-01-05 00:49:14
问题 When I use below to get the user object it works just fine. @GetMapping("/findOne") @ResponseBody public Optional<AppUser> findOne (Long id) { return appUserRepository.findById(id); } Above gives me a response back as: {"id":1,"useruuid":"863db606-9af6-48a8-963a-07b9fe0fc4fc","useremail":"user1@mydomain.com"} Now, I am trying to search based on UUID(4) using this: @GetMapping("/findOneUsingUUID") @ResponseBody public AppUser findOne (String useruuid) { return appUserRepository.findByUseruuid