Skip to content
Advertisement

Tag: jpql

JPQL issue updating records

Trying to update a record in a database but getting this error: Code below is responsible for inserting it Im not sure if there is a type issue with propId being a Long or if i have written the SQL paths wrong or both. Answer You’re trying to execute an SQL query as JPQL. There are a couple options to

JPQL query that give me the highest value

I’m trying to do a JPQL query that give me the highest PK of the PKs in my table (https://drive.google.com/file/d/1_kaklkKdCbhT0-byqCtz6HgfluKKp8J-/view?usp=sharing). Here is my query : The error says that the syntax of my query is wrong. Can someone please help me ? Thank you for your help 🙂 Answer Thank you for your comments ! It allowed me to solve

Showing a specific JSON response for my GET endpoint

I have a many-to-many relationship between Department and Employee I have already done a mapping for the GET endpoint which returns a list of departments that contain Employees, this is the request: http://localhost:8080/api/departments/1/employees, and this is the response I get: This is the code that gets the job done: Department Repository Imp Employee Service Impl Department Controller Now what I

How to handle an error when database returns null value for one of the columns in the table

I’m using Java and Spring Boot with JPQL to access the data. I’m getting the below error because hourlyRate is null in the database: Caused by: org.hibernate.QueryException: could not instantiate class [com.example.model.response.school.Employee] from tuple. I still would like to be able to get the data from the database even when that column has null value in the database and send

How use generic entity name in JPQL

I have three tables with same column name and types, what changes is just the table name. Example: | TABLE1 | TABLE2 | TABLE3 | | —— | —— | ——- | | ID | ID | ID | | NAME | NAME | NAME | | FOO | FOO | FOO | | BAR | BAR | BAR |

Passing a query as a query parameter in JPQL Native Query

I’m trying to pass a query as a string parameter in another JPQL native query. So the resulting query would be something like the query below that returns me a value but what I’m getting in return is only the string of :query parameter and not the result of the executed complete query. Answer Create an interface for a custom

How to check UUID null value in JPQL?

I am using JPA/Hibernate. So I wanna to do nullCheck in JPQL, but when I do that it does not determine dataType. JPQL Query: EXCEPTION: Caused by: org.postgresql.util.PSQLException: ERROR: could not determine data type of parameter $1 at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2532) at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2267) at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:312) at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:448) at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:369) at org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:153) at org.postgresql.jdbc.PgPreparedStatement.executeQuery(PgPreparedStatement.java:103) at jdk.internal.reflect.GeneratedMethodAccessor582.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at org.apache.tomcat.jdbc.pool.StatementFacade$StatementProxy.invoke(StatementFacade.java:114)

Advertisement