incorrect @query in spring boot – Postgresql
I am trying to use this query in springboot so I can display the results in a webpage. I know that this query works because I tested it in postgresql and it gave me the right results. But JPA is…
I am trying to use this query in springboot so I can display the results in a webpage. I know that this query works because I tested it in postgresql and it gave me the right results. But JPA is…
I am using Springboot JPAs to generate a MySql8 table. It works fine unless I try to use the columndefinition in the Column annotation. @Column(columnDefinition = "boolean default false") private Boolean example; I tried replacing boolean with TINYINT but MySql8…
I want to test my orderService, each order has x cartItems, each cartItem is a product. I managed to do some code, and thought I got it right, but encountered a problem : java.lang.NullPointerException: Cannot invoke "com.proj.my.repository.OrderRepository.save(Object)" because "this.orderRepository" is…
I am using Spring boot with Mysql. I have implemented Datasource and defined properties in application.xml file. I have a long running query: @Query(value - "select sleep(10)", nativeQuery=true) public void test(); in JPA repository methods. I want to implement query…
I'm using Spring boot, and I Run this model. package com.example.demo.Models; import jakarta.persistence.*; @Entity @Table(name = "user") public class UserModel { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(unique = true, nullable = true) private Long id; private String name; private String email;…
I have to get total price in month from a date yy-mm-dd with jpql query but I can't do it. @Query(value = "select new com.talan.food.dto.MonthIncomes( function('date_format',date,'%Y-%m'),SUM(p.price)) from Reservation p group by function('date_format',p.date,'%Y-%m')" ) public List<MonthIncomes> getIncomeByMonth(); And in the table…
JDK 17 SpringBoot latest JPA latest MySQL 8.0.31 I am trying to implement a strategy that makes sure that both the name and the email address of each user are unique. User entity: @Entity public class User { ...... @EmbeddedId…
I have an entity where I want to generate value like this. like this id tenant 1 1 2 1 3 1 1 2 2 2 3 2 1 3 2 3 3 3 Keep in mind that multiple instances…
I try to create a relation between two tables in a Spring Boot Application. I have the following Code: @Entity @Table(name = "account") @Getter @Setter @AllArgsConstructor @NoArgsConstructor @Builder public class Account { @Id @Column(name="ID", nullable = false, updatable = false)…
In Postgres I need to sort text with natural order, but with one exception - if the string has only number, it should be placed at top. So I need such order: ["98", "125", "134", "148", "265", "634", "1233", "5231",…