I have these 2 tables: inventory and product_categories both tables have a common column called businessId. Now I have 2 databases, one is hosted on MySQL and the other on Derby both databases have same table structures. So I’ve been executing the following query on both databases: When I execute the qu…
Tag: java
I/O error while reading input message; nested exception is java.io.IOException: Stream closed
This is my controller: This is the error I get: “message”: “I/O error while reading input message; nested exception is java.io.IOException: Stream closed” Answer Your error is the result of @RequestBody being used twice in your controller method arguments. Following line causes the iss…
Is possible to use an expression logic on @Formula which has a boolean field to compare dates?
I’m trying to know if the following example works with @Formula of hibernate, perhaps someone can help to solve the other ways, to use sql or queries. When I do that example get the following error: 2019-03-03 05:29:57.568 ERROR [service_a,4fedd46e4085e86f,4fedd46e4085e86f,false] 608 — [nio-8090-e…
How to improve JPA Query performance and response time on multiple Join tables and conditions
I am very fresh java beginner and I am trying to implement possibility to review documents. User, who belongs to a certain group can review documents of particular types that are assigned to that …
How to log failed sql in hibernate?
I’m building a SpringBoot application with spring-data-jpa. I know how to log all sqls from this question. How to print a query string with parameter values when using Hibernate But what if I only want to log failed sqls? Answer There are two options: Configure sql logging with parameter values. Disable…
@Where with @SecondaryTable does not work with Hibernate
There is a one-to-many relationship in my model, where the child entity is stored in two tables. @Entity @Table(name = “child1”) @SecondaryTable(name = “child2”, pkJoinColumns = { @…
how to fetch data from two tables in JPA
I am not able to fetch all records from two tables using the below query I have tried this but I am getting a result from one table only. I want a result of both the tables i.e, …
Postgres convert date time difference into HH:MM:SS
Ex: Diff is 0 years 0 months 5 days 20 hours 6 minutes 30 seconds. I want to convert this into HH:MM:SS format : 120:06:30. Answer tl;dr java.time Doing it on the Java side is simple with a column of a data type akin to the SQL-standard TIMESTAMP WITH TIME ZONE and driver compliant with JDBC 4.2 or later (for
Return primary key value generated by default in H2 database upon INSERT of new row, for UUID type column
When using a UUID data type as the primary key of a table, and asking H2 to generate each UUID value by default upon INSERT of a new record, how does one access the value of the newly generated UUID value? I am using plain JDBC 4.x in a Java app, if that helps with a solution. I know SCOPE_IDENTITY
Java sort list alphabeticaly with value “Other” at the end
I got a small Spring Boot application that manages some projects and clients. A client has a country ( which is an entity) and I want to let the user when he wants to create/update his clients to …