Skip to content
Advertisement

Tag: java

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 next as task3, I also

Creating JDBC Application

I have this piece of code: but I have this error: Answer Since you commented out your print statement, your loop is now closing the connection (and all of its dependent resources). Your code, without the commented out line:

Spring Data JpaRepository “JOIN FETCH” returns duplicates

I’m writing a simple Spring Data JPA application. I use MySQL database. There are two simple tables: Department Employee Each employee works in some department (Employee.department_id). The method getAll returns a list with duplicated departments (each department is repeated as many times as there are employees in this department). Question 1: Am I rigth that this is a feature related

How to use JPA to save datetime of SQL to fix: “Conversion failed when converting date and/or time from character string.”

I got a very frustrated problem.. I cannot use the JPA save function to store correct datetime object of SQL, I got the following error: There is my code: In Controller: In Entity: Many thanks!! Answer I recomend you to use LocalDateTime of modern java.time. JPA automatically convert LocalDateTime into database datetime. To get current datetime use LocalDateTime.now(). You can

Advertisement