Skip to content
Advertisement

Tag: spring

Populate DTO using query with JOIN

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

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

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

Advertisement