Skip to content
Advertisement

Tag: jpql

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. Answer Ugh….. false alarm.

SQL code does not work when converted to JPQL code (ORA-00904 error code)

Thank you very much for looking at this post :). I have the following problem: I have a piece of SQL code that runs perfectly on the Oracle database. The problem comes when I try to run as JPQL code. I get the following error in the Eclipse IDE: Internal Exception: java.sql.SQLSyntaxErrorException: ORA-00904: “THIRDTABLE”.”NAME”: invalid identifier. The SQL that works

Need Help Converting a SQL Query to JPQL

So far, Spring’s JPA repositories have sufficed for me, but now I need a custom query. I have struggled with this for a day trying to learn more about SQL, joins, etc and came up with a native MySQL …

Hibernate Null Attribute Value using Camel-Case

Using Hibernate 5.3, Spring Boot 2.1, MySQL, that runs in Windows 10 OS. What I know I have verified on my phpmyadmin the case of the attributes. And as long the case were the same as the attributes of my Entity class you don’t have to explicitly define the column name in that Entity. And using @Column(name=”tableattribute”) is not required.

My custom order by in criteria query/jpql

Is it possible to do my custom order by using criteria query or jpql in Java? In my table, I have a column – number type(for now, this column includes numbers such as 1, 2, 3, 5, 10). I would like to sort result in this order 2, 5, 1, 10, 3. How can I do it? Answer You have

JPA distinct inner join with Condition on joined table

I have two tables below: I want to get the college object with list of students of a specific department. The SQL query is below: So far I have tried the below JPA query but it is returning multiple College objects. How to return a single college object with list of students with filtered department? NOTE: I can’t alter the

Substring in select statement in JPQL

I’m trying to select a substring of column, i.e. select substring(description, 1, 200) from category where id=1 Is it possible to have a substring function within a select statement in JPQL/JPA 2? If yes, how? If no, are there any alternatives? Thanks. Answer There is a scalar expression for this: SUBSTRING(string, start, end) I believe this is allowed in the

Advertisement