I have this main Product table: Additional table for storing categories that should be returned as List: Additional table for storing Payment Methods that should be returned as List: I want to return a result like this: I tried this: What is the proper way to populate this DTO? Answer If, as indicated in your comments, you need query your
Tag: spring
Will Converting my H2 memory database to a SQL database mess up any actual logic on my project? Spring Boot
I am currently using the H2 memory database for my website. Everything is working so far but to progress my teacher said to transition from the h2 database to a SQL since it resets everytime you restart the program. I was wondering if I transitioned, would it mess up any of my logic / code. I know I would have
Spring Data JpaRepository “JOIN FETCH” returns duplicates
I’m writing a simple Spring Data JPA application. I use MySQL database. There are two simple tables: Department Employee Each employee works in some department (Employee.department_id). The method getAll returns a list with duplicated departments (each department is repeated as many times as there are employees in this department). Question 1: Am I rigth that this is a feature related
(N + 1) selects problem with child Map-collection
friends! I have these entities: Document: and ChangeNotice: And these are my repositories: For Document: and for ChangeNotice: So, when i want to get Document with changeNotices, thats not a problem, i have only one select. But when i want to get ChangeNotice with documents – i have (n + 1), first for document, and n for changeNotices Map. I
Something wrong with this SQL query?
Is there something wrong with this query? SELECT id, ( 6371 * acos(cos(radians(?1)) * cos(radians(latitud)) * cos(radians(longitud) – radians(?2)) + sin(radians(?1)) * sin(radians(latitud)))) …
Java SQL problem executing query through CallableStatement with parameter
I have a problem in a CallableStatement that execute a stored procedure query which accept a parameter. I have a list of string that contains the query like: I have a list of string that contains the parameter like I have no SQL syntax error when I run but the result set doesn’t have any value. The expected result of
Are these SQL queries equivalent? And which is better or is there a better option?
I am working on a Spring web application that utilizes hibernate to connect to a DB2 database. I am try to optimize a service method that gets called may times during a wed service call by reducing …
How to add entity to the databse without adding related entitiy in DB as well?
I have a problem adding one entity using JPA save without error : JdbcSQLIntegrityConstraintViolationException: NULL not allowed for column because i add empty entity to the object i want to save. how can i save one entity and tell it’s related one to ignore this transaction? For example i have student and i have student_info OneToOne Relationship. I want to
For SQL Server database getting “com.microsoft.sqlserver.jdbc.SQLServerException:The statement must be executed before any results can be obtained.”
I am getting above error when trying to perform insert operation from java application using JDBCTemplate. org.springframework.jdbc.UncategorizedSQLException: PreparedStatementCallback; uncategorized SQLException for SQL []; SQL state [null]; error code [0]; The statement must be executed before any results can be obtained.; nested exception is com.microsoft.sqlserver.jdbc.SQLServerException: The statement must be executed before any results can be obtained Answer Change prepare call to
How to implement pagination by nextPageToken?
I am trying to implement pagination using nextPageToken. I have table: CREATE TABLE IF NOT EXISTS categories ( id BIGINT PRIMARY KEY, name VARCHAR(30) NOT NULL, parent_id …