I have the following query: However, this throws a syntax error on the query when I put a case statement inside an aggregate. I can get SUM to work fine alone, and case statements to work fine alone. I’m wondering whether JPQL can support cases in aggregates or if I’m forced to use a native query. Answer Ugh….. false alarm.
Tag: java
Is it possible to fetch and compare an element which resides in a nested Json string format column in database? Via SQL Query
I have ‘a unique-id’. I want to fetch records from table on basis of that unique-id. I have a column named “request body” that contains a nested json string which is of type text. Is there any way i can compare ‘unique-id’ with the ‘unique-id’ inside the json string cloumn i-e request body? Answer Apologies, I am new to stackoverflow.
Delete cascade Category child (Java Hibernate JPA)
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
How to prevent unintended default values from MyBatis queries?
I have the following Java class: The class represents a database table called example. I can use the following SQL query to fetch Example instances from the table with MyBatis: Let’s say that I will add a new field to the table and the class: boolean third. However, if I don’t remember to add the field to the select queries,
How to select and view database with specific value?
So I’m trying to search and print the value from the PHPMyAdmin database. But the result shows all row which has variable with containing the value. Like when I try search variable int bulan that has value 2. This also shows a row that has a value of 12, 22 or 23 as a result. this is my code Answer
iText PDF: the document has no pages
I’m trying to do a date range based filter to export a report into a PDF; however, when I click to export the PDF, I get the following message: ExceptionConverter: java.io.IOException: The document has no pages. Here’s my PDF class’ code: And here’s the code of the PDF generation button: I believe there’s a problem with SQL and JDateChooser, since
Is a rollback necessary when insert of a single database record fails?
I am not too familiar with database transactions. I was wondering about a situation where a single record is being inserted into a database. Is a transaction necessary. If so, if the insert of the one record fails, is a rollback necessary? I am asking this related to JDBC but is can be in a general database sense. Answer From
Optimize Merge query inside n^2 loop
I’ve got a merge query that needs to be executed one time for each combination of day and sessionType inside the request ArrayList. I am using nativeQuery to execute it. Is there a way to plain the source data (two ArrayLists, one with a date range instead a single day, and the other with all the session types), so I
Why is it not updating
I’m trying to update my database where in the Book copies will be updated to 5 depending on the Book code. The Book copies I initialize in the database was 10. For now, I have a fixed value of 5 to change it. My plan is to decrement the copies by 1 if users borrowed it. But for now, I’m
Creating dynamic table in JSP
I’m trying to do electronic grade book in Java. I want to insert values of Marks and Description into rows But when I try to add Description to row, it looks like this: Is there any way I can also add description to the 3rd row? I tried many solutions and any of the solution I tried didn’t work. Answer