Skip to content

Tag: hibernate

How to use SUM(CASE WHEN….) in JPQL Hibernate?

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.…

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 …

Hibernate Table or view does not exist Oracle

I Have a problem executing an hibernate query on Oracle: my persistence.xml: my entity class com.entity.User: my java class: but when i execute my code, i obtain: Can you help me to find the error? NOTE: if a use a PreparedStatement with the same connections and query i don’t have any issue, so it is no…

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 …

How to create LinkedList of JPA entities

I have a scenario where I need to create an entity which has references to list of predecessors and list of successors. when a request is received, I need to create entity like below: Request: My new entity “task2” should now be created as below in DB. While saving task2 with previous as task1 and…