3,221
questions
1
vote
0
answers
27
views
Calling stored procedure with Hibernate which multiple type of outputs
I have a stored procedure from my DBA team. Here is the stored procedure, and temp table created. All I want to know here, how to map the temp table to the output value while calling the procedure in ...
0
votes
0
answers
74
views
Spring JPA using Stream as batch read together with JOIN FETCH not work
I am writing a cron job to fully dump some tables from a database to a CSV file. The table content is quite large, with more than 1 million records, which is why I chose to use JPA Batch Reading. I ...
0
votes
0
answers
65
views
Supporting JPA Sequence and UUID IDs at the same time
I would like to support UUID and Sequence IDs in my JPA entity class in different situations.
Case 1: For existing deployments I would like to use the sequence number
Case 2: For new deployments I ...
2
votes
1
answer
86
views
How to use JpaRepository method in the Jpa Entity Lifecycle callbacks?
How to create new Transaction in the @PostUpdate JPA Entity Lifecycle methods? I am not able to @Autowire the AuthorRepository method there and it's always coming null.
package com.bookstore.entity;
...
-1
votes
1
answer
33
views
How to fetch inversely joined entities in a single query?
I have 2 entities, Student and Note:
@Entity
public class Student {
@Id
@GeneratedValue(strategy = GenerationType.UUID)
private UUID id;
@OneToOne(fetch = FetchType.LAZY, mappedBy = "...
0
votes
0
answers
29
views
Upgrading from Hibernate 4.x to 5.x producing SQLException Invalid Column Index
Currently my application is having Hibernate 4.x. Since Spring 5.x requires Hibernate 5.2 or later, I am trying to upgrade it to 5.2.6.Final
ivy.xml
<dependency org="org.springframework" ...
0
votes
1
answer
252
views
Cannot create a table in H2 with a custom enum
We have an entity, let's call it Test.
@Entity
@Table(name = "TEST", schema = "KAA")
public class Test implements Serializable {
@Id
@Column(name = "ID", ...
0
votes
0
answers
51
views
JPA criteria select multiple fields from subquery
I have the following SQL query that I'm trying to write using Criteria JPA.
select op3.* from operator op3 where (op3.mp, op3.date_to, op3.date_from) in
(select op.mp, op.date_to, op.date_from from ...
0
votes
0
answers
795
views
Spring boot 3, javax.persistence and entity scan
I know there are lots of questions and discussions about spring boot migration from 2.7 to 3.x, but I was not able to find an answer on my (specific) problem.
I have a plugin that is needed by 2 ...
1
vote
0
answers
44
views
Issue with Jpa and inheritance
I've tried to implement some sort of inheritance between 2 classes but eclipse-link fails at the end.
I've got a Product class:
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
@Table(name=&...
0
votes
0
answers
107
views
Joining pageable tables without relation using JPA criteria
I have two tables with no modeled relations. in my custom repository like below:
Method one
public Page<HistoryTable> findInquiryhistory(InquiryRequest req, int pageNumber, int pageSize){
...
1
vote
1
answer
80
views
JPA ElementCollection foreign key mapping error
My simple Entity class looks like this -
Entity
@Table(name ="my_class", uniqueConstraints = {@UniqueConstraint(name = "AAndBAndCAndD", columnNames = { "A","B",&...
0
votes
1
answer
23
views
JPA [EcliseLink]: Cannot change the type of an instance of parent A to subclass B In the single table inheritance
I use Eclipselink-2.6 with wildfly-8 server in a JavaEE7 application.
I have three JPA entities A, B, and C.
B and C extend A.
I need to change the type of an entity instance myObjectId A to B, ...
0
votes
1
answer
32
views
SpringBoot JPA in MySQL
I defined this class:
@Entity
@Table(name = "t_planets_tropical")
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class PlanetsTropical {
@Id
@GeneratedValue(...
0
votes
1
answer
218
views
In JPA2 and Java 10, how do I map the value of an enum to an @Enumerated column?
I'm using Java 10. If I define an enum like this
public enum MyEnum {
NAME1("value 1"),
NAME2("value 2"),
...
}
and then I have a JPA-mapped database column that is ...
2
votes
1
answer
94
views
can do this with JPA / Hibernate criteriabuilder
I am working with oracle and using JPA with Hibernate, can we do this with criteriabuilder?
SELECT col1,col2,col3
FROM table(schema.fn_name(param1,param2,param3))
ORDER BY col1,col2;
the query can ...
0
votes
1
answer
139
views
JPA Criteria Subquery with select multiple colums and max() function
I need to write the following SQL code in Hibernate criteria query:
SELECT
a.*
FROM
objekt a,
--Filter on max version
(
SELECT
ueb_uuid,
...
0
votes
1
answer
430
views
How to properly / efficiently manage entity manager JPA Spring @Transactional for large datasets?
I am attempting to insert ~57,000 entities in my database, but the insert method takes longer and longer as the loop progresses. I have implemented batches of 25 - each time flushing, clearing, and ...
1
vote
0
answers
53
views
Build a jpa specification query without retriving child entity data
I'm trying to build a search query to find all Test entity data.
Here are my classes...
TestParent.java
@Entity
public class TestParant{
@Id
@Column(name = "id")
@GeneratedValue(...
0
votes
1
answer
469
views
findAll() in spring boot
When I try to select all details of my database, I don't get data s into a table structure in my jsp page. The array is printed in my jsp but don't know how to make it single objects.
Here is my ...
1
vote
1
answer
68
views
Shared column between FK and PK
I have two tables, A and B (not defined by me, inherited from old legacy software), with the following structure:
A: PK (idA, ente),
B: PK(idB, ente), FK(idA, ente) --> A
I need to use @IdClass/@...
1
vote
0
answers
242
views
"No explicit selection and an implicit one could not be determined" error for my JPA request
I have three SQL tables
The "Accedant" table that has an idAccedant
The "Emetteur" table that has an idEmetteur and a foreign key towards the Accedant table
The "...
0
votes
1
answer
727
views
JPA CriteriaQuery Generated SQL with hardcoded parameter on nested entity id
I've been studying SpringData JPA and came across with this weird behavior when using CriteriaQuery to find a given entity by its child entity's Id, I've noticed a hardcoded child_id parameter in the ...
0
votes
1
answer
173
views
@OneToOne Composite Primary Key of Entities
I need help for this case.
I have the following entities (I removed getters/setters/hash/toString for easy reading):
@Entity
public class Company implements Serializable{
@Id
...
1
vote
3
answers
627
views
How to begin transactions, In Spring boot JPA
I have a composite unique constraint in the database and i wish to violate it inside the transaction but it will be upheld after i call commit.
It's pretty basic database transaction, but i am not ...
0
votes
2
answers
267
views
JPA: unidirectional many-to-one and cascading all
Say I have a unidirectional @ManyToOne relationship like the following:
@Entity
@Table(name = "TestUser")
@AllArgsConstructor
@NoArgsConstructor
@Getter
@Setter
...
0
votes
1
answer
981
views
JPA criteria API uses SQL server convert function
My DB has 'm_date' which is of string type and stores dates as "dd-MM-yyyy" format. Now I want to fetch the records from the table with the help of the JPA criteria query between filters.
...
0
votes
1
answer
444
views
REST + Spring Data JPA entity graph + entity not fully load + cache
When loading entity not fully with specification and entity graph in repository query, the data were cached. But only when method is called over REST endpoint. When the method were called scheduled ...
0
votes
2
answers
580
views
JPA / Criteria API - How to filter a OneToMany field?
Data domain (kind of email model) :
- Message(id,subject,messageAttachment) OneToMany MessageAttachment(messageId,attachmentSHA1,message)
- Message(id,subject,messageAddress) OneToMany MessageAddress(...
2
votes
1
answer
713
views
Creating JPA repositories dynamically depending on the request attributes
I have a requirement like one API REST endpoint which will be connected to 3 databases. In this API, three service implementations, each service will connect to separate database.
I have to use Spring ...
0
votes
1
answer
348
views
TypeMismatchException on fetching the table data by Hibernate Session.get() method
In a application, having a database table CUSTOMERS defined as:
create table CUSTOMERS (
ID varchar(10),
CODE varchar(10),
CID varchar(10),
SID varchar(10),
FNAME varchar(50),
LNAME ...
0
votes
0
answers
446
views
gradle/intelij - not generating hibernate meta model classes?
I am using inteliJ as IDE and Gradle as build tool.
Following this article on MetamodelGenerator , I have configured annotation processor on intelij as suggested.
And my gradle file is as below. I ...
0
votes
0
answers
56
views
Websphere 9 throw random database exception
I am using websphere 9, ejb application . Till now I didn't face any errors. But suddenly after restart the server, the application throwing database persistence exceptions . And it fixes after ...
0
votes
0
answers
140
views
JPA Many to Many with Intermediate Table and MapKey*
I'm struggling to setup the following JPA mapping (extra cols, etc. omitted for brevity)
----
id: primary key
organization
------------
id: primary key
z
role_assignment
---------------
...
0
votes
0
answers
361
views
JPA delete @ManyToOne Entity on EAGER collection
Very simple problem, but it looks like is impossible to achieve what I want
The entities:
public class C {
@OneToMany(fetch = FetchType.EAGER, cascade = {CascadeType.PERSIST, CascadeType.REMOVE}, ...
1
vote
1
answer
3k
views
Unknown Source when querying database with JPA
I have a strange error when running tests in SpringBoot using JPA to interact with a postgresql database.
A test class successfully inserts an entity to the database and I can see it exists, but when ...
0
votes
1
answer
132
views
Join fetching with FetchMode.SELECT using Hibernate and JPA2 Criteria
I'm using JPA2 Criteria API with Hibernate.
The simplified database schema is as follows
@Entity
public class Order {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long ...
1
vote
2
answers
427
views
One to many associated entities are not getting deleted with Spring Data JPA
I have a one-to-many relationship between two entities Order and LineItem. I also have a parent to Order entity which is Customer and Customer to Order is one-to-many. When I try to delete the order ...
1
vote
3
answers
122
views
JPA 2 Entity with composite key generates extra redundant *_KEY field in databse
I'm rewriting some XML configurations to entity classes and I'm experiencing problems with hibernate generated tables.
This is my original XML config for this relation:
<map name="rates" ...
-1
votes
1
answer
64
views
SpringData - Can a Map<String, @Embedable MyClass> be persisted with @ElementCollection if MyClass contains another Map<@Embeddable, @Embeddable>?
I'm currently implementing JPA persistence with Spring Data and I'm not able to solve the following problem so far:
The problem
I have an @Entity EntityClass which has a Map<String, @Embedable ...
0
votes
1
answer
54
views
How can we write JPA query for below SQL query
how to write jpa query for below sql without using native sql query
select * from emp where emp_id=123 and (emp_name="ABC" OR emp_name is NULL) order by salary
0
votes
3
answers
1k
views
How to map specific column in entity class
I have two tables Users and UserRoles. These are the entity class I have created,
@Entity
@Table(name="users")
public Users {
@Id
@Column(name = "id")
private Long userId;
@...
0
votes
1
answer
62
views
When using JPA2 EntityListener, how does it work if i use the in clause to update multiple rows?
query : update Order set f='1' where key in (1,2,3,4,5)
@PostUpdate
public void postUpdate(Order order) {
....
}
I wonder what happens if I work as above.
1
vote
1
answer
700
views
Hibernate 5 migration Issue with Multilevel Joined table Inheritance with Hibernate 5.4 DiscriminatorColumn
I am working on migrating a legacy Hibernate project from version 4.1 to 5.4. The code has Multilevel Joined table inheritance using a dedicated DiscriminatorColumn. The code was working fine in ...
0
votes
1
answer
5k
views
How to fix JPA Specification API with join on condition returns 2 query instead of 1?
I have a requirement to form a query using JPA as;
select PARENT.ID, PARENT.NAME, CHILD.ID, CHILD.STATUS FROM PARENT
LEFT OUTER JOIN CHILD ON PARENT.ID=CHILD.ID AND CHILD.STATUS in ('Active')
WHERE ...
2
votes
0
answers
29
views
Would upgrading Database Versions change the Exception Call Stack Potentially?
In my code, I was persisting a row of data and had a catch block to throw a (custom) error when a constraint violation was thrown at the DB level. It was a bit messy how I had to get there but it ...
0
votes
0
answers
314
views
Criteria Query JPA with pair wise IN clause
I have this following query.
I need a way to write it using JPA criteria Query.
Select a from alpha a where a.id in (select b.id from beta b where (b.tag_key,b.tag_value) in ((:paramkey1, :paramval1),(...
2
votes
1
answer
115
views
Understanding Relationship Cascading with Merge
Deep diving into Spring JPA and I have troubles to understand whats going on here.
This is the code:
Entity
@Entity
public class PersonP {
@Id @GeneratedValue
private int id;
public ...
1
vote
1
answer
8k
views
How to solve java.lang.IllegalArgumentException: Unsupported class file major version 61 and Entity was compiled with an unsuppported JDK
I am trying to develop an app with a database and i got lots of error like
java.lang.IllegalArgumentException: Unsupported class file major version 61 and [EL Severe]: metadata: 2022-01-26 17:43:20....
0
votes
2
answers
3k
views
JPA one-to-one mapping creates an extra column. How to remove it?
I have one-to-one mapping JPA table in my springboot application which works fine.
The Users is the parent table and in the account_no column, it stores the foreign key. Which is, child's primary key. ...