I am trying to test a few things out with postgres. I want to know if it’s possible to create define a PreparedStatement such as String statement = “Insert into table_one values (?)”; …
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:
JOOQ materialized views
is it possible to create materialized views using the JOOQ builder? Something like this DSL.createMaterializedView().execute()
Flyway don’t clean database correctly, and execute migration files two times
I’m using flyway for migration database, as well I use FlywayTest for my integration tests, but When I create a test using : I get this error : If you not : This comes from FlywayTestExecutionListener.class but it migrate the database again. Why flyway do this, and how can stop this. More details The problem is not happen when I
Using BETWEEN in native query in JPQL
I tried to make a query using BETWEEN in JPQL, I already tested it in SQL and it works, but when I implemented in JPQL I got an error: Caused by: javax.persistence.PersistenceException: Exception […
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
Invalid Number Exception in SQL when trying to call select statement from Java
I am trying to call a select query from my Java Program but i am getting Invalid Numbererror. I am trying to call the query something like this code I am getting query something like this: Result I am getting the error Invalid number in the line P.PACKAGE_ID = {0}. I gone through and come to know that if i
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
Java SQL problem executing query through CallableStatement with parameter
I have a problem in a CallableStatement that execute a stored procedure query which accept a parameter. I have a list of string that contains the query like: I have a list of string that contains the parameter like I have no SQL syntax error when I run but the result set doesn’t have any value. The expected result of