I have this Entity to represent a Category system with a selfrelationship to get child categories: The problem is when I want to delete a category that has child categories. I want to delete all child categories but Java drops me this exception : Cannot delete or update a parent row: a foreign key constraint fails (vanger.producto, CONSTRAINT FKju4fpj8umbyi05750yjm70cx0 FOREIGN
Tag: spring-boot
JPA query is throwing a ‘not found’ error for column that isn’t in query
I’m trying to call for only specific columns in my DB but the query is throwing an error saying that the next column is not found (even though it’s not in the query) Is there a problem in the join that’s doin this? I’m a bit perplexed as to this problem. JPA Query from ConnectionRequestRepository – Service – Controller –
Why are postgresql tables empty although filled when starting Testcontainer?
I am using Testcontainers 1.15.2 (using postgres image 13.2-alpine) with Spring Boot 2.4.3. The Testcontainer is started using an init script which starts with a type definition, a table creation and …
Spring Data Jpa to get data which doesn’t have entity representation
I’m trying to find the best way to map my data on ORM. I have a query which gets me data from MySQL database which look like What would be the most optimal way to get these data with Spring boot and Spring data?? Should I use @Query annotation and execute this or somehow create entities for Equipment and Devices
How to import data from one table to another – SpringBoot JPA /MySQL
I recently created a vehicle management system The system is derived from MySQL database and server side in spring I want to create another table (automatically at runtime) that will display only 2 of the columns of the existing table. And the question is what am I doing wrong? Final goal – when adding / deleting / editing a vehicle,
Boolean value not being changed in database
Hey folks I’m having a problem with my code. For some reason when I try to change the value to false, it doesn’t reflect in my SQL Database. I debugged and it does get set via Java, but it doesn’t transfer over. I’m working on a notification service class and it sets the values on there to true no problem,
Create new PostgresSQL schema
What’s the easiest way to create a new Postgres scheme inside the database on the runtime and also, create the tables written inside a SQL file? This is a Spring boot application and the method receives the schema name that needs to be created for the db. Answer Although it sounds like this would be a case for using Liquibase
SQL Grammar Exception in Spring Boot H2
I’v got a problem in my Spring Boot with H2 project. I got a get method for listing elements from the SQL table and the SQL command working. In the H2 database I can execute and see the results but I …
org.hsqldb.HsqlException: discrepancy in the number of rows counted
I’m trying to play around with an insecure application (Insecure Bank) and I’m trying to port it to secure it a bit more as a personal project. I have a problem inserting the contents of the database …
Problems with JPA Hibernate Query with ‘Interval’
I need the possibility to retrieve the orders for the past 6 months for my backend application. After some research , I’ve found out that JPA does not support the INTERVAL definition. Is there a workaround for archiving this particularly function ? Answer In that case use the JPA provided functionality , where native sql code is not required. and