I have a Spring Boot application with a JpaRepository. I am trying right now to obtain all the unique values for a certain field in my db. Let’s suppose I have an object Foo with an Integer PK id and a non-unique Integer field bar. I want to get all the unique values for bar and I’m wondering which query
Tag: sql
Springboot/Thymeleaf – How to execute a different SQL query based on the URL?
I would like to be able to display different data based on the previous category that was selected. For example, I currently have categories, that once clicked should redirect a user to a new page that displays all the relevant information for that category. The url should look something like localhost:8080/category/321 where the ID of that category is last. I
Why in Postgres, with an empty table, if I use BEFORE INSERT, the :NEW: variable is NULL?
I’m developing a Cinema Database in PostgreSQL. I have a Trigger which, before I insert a new show, checks if the date of the show is prior the movie’s release date (for example, adding today a show of Avatar 2). Here’s the code: Thing is, if the SHOWS table is empty, var1 is NULL. Already checked with a ‘raise notice’.
Create Trigger to update the record that was newly inserted on PostgreSQL
I want the trigger to fire when a new record is inserted, and update that newly inserted record to add a current date and time, need help please be kind still new here 🙁 here’s my code: FUNCTION: TRIGGER: Answer Your WHERE condition is needlessly complicated (and slow) as you could replace it with where owner_no = new.owner_no as you
Combine JPA Query annotation with Oracle sample method
i am trying to pass a parameter into a JPA query Example code But i get an error because of the sample(:percentile). If i just hardcode a number in there it works but not with a param. Is there a way to escape the brackets or something similar? Thx Answer The error is on the following part Unfortunately it does
How to extract JSON from sql query?
My query looks like this: I want to retry the messages that failed, but the message is a json string and the offset is a regular string. I need to extract the json messages and the offset strings and then iterate through each row. How would I do this? RIght now I am doing something like this: //Service buildQueryResult() simply
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
Date conversion format Java to DB different format
I’m making a code in java that executes an Oracle database procedure The format I have to put there in the procedure when I run through the database is dd/MM/yyyy. I have to send this date from my java code using a CallebleStatement setDate with the date yyyy-MM-dd (which is the Date format in java) When this CallebleStatement is executed,
JPA SpringBoot – Unable to Save New Entity to Database
I am attempting to add (save) a “User” to my SQL database through my Spring application (The @GetMapping requests currently work). I recently added the two annotations @CreationTimeStamp and @UpdateTimeStamp in my entity class…the version without those two annotations would produce the same errors as shown. I am testing the API with Postman-here is my Users entity class: my UsersDTO
Query did not return a unique result
This is the query I have written: This is the output I am getting from the database: id versions 101 0.0 101 1.0 101 2.0 101 3.0 In my application, I am storing this result in but it gives an error saying “query did not return a unique result” How can I store this result? which data structure could I