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 |
Tag: jpa
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 Crea…
Spring repository saveAll inserting duplicate rows for mapped entity
I am trying to insert a list of entities which have one to one relation to another entity. It is possible that the one to one mapped object would be same for many parent entity. I am expecting that the same child entity is referred in foreign keys of parent, but actually duplicate rows are getting created. He…
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(QueryExecu…
JPA generated column name doesnt have underscore (column name mismatch)
I have a composite FK which acts as a composite PK. A part of this composite key is Fk to users table and the files are as follows: Users Unit looks like below: UsersUnitPK: UsersUnit: User: I get run time exception as follows: Caused By: java.sql.SQLSyntaxErrorException: ORA-00904: “LKUNIT1_”.…
Java code refactor with stream Collectors.groupingby()
I try to get a Map with Collectors.groupingBy() but I have no idea how to create… I have a List from jpa jquerydsl the data is like [memberId=1, departmentId=1] [memberId=1, departmentId=2] [memberId=2, departmentId=3] [memberId=3, departmentId=4] this is my Member class I want to parse tuple list to me…
Getting errors in getting collection for ManyToMany JPA+Hibernate
I have two classes. A film that keeps authors in it. And the author himself. I want to make the connection ManyToMany for them using EntityManager, where then I can get the data for Set. Class movie: Class author: Method, where i add authors for movie and push to database: Get movie with authors: But i get mo…
Who should be parent in spring JPA relationship
I have 3 tables book, publisher, author. Here author and publisher can refer to same record in book therefore I decided to make book as relationship parent. However I also want to make it so that if a publisherA is deleted, all the book record related to publisherA also get deleted. same goes for author. I tr…
Execute sql native query from two entity using jpa or hibernate
I have 2 tables, salesOrder with column “id”, “customerId”, “textReview(boolean)” and table SalesOrderline with column “salesOrderId”, “productId”. i want to change boolean data in textReview column. I got data from the client in the form is customer…
Hibernate Native SQL returns some nulls instead of partially filled objects
I have the following (postgress) SQL Query: And what it does is it creates a series of 6 hours per day and takes averages from it. A result may look like this: variable_id date_time sample_count sample_period_ms min_value max_value value 15 2021-06-06 06:00:00 120 59577 -1.4960686 1.1995025 0.3043984425413674…