Questions tagged [hibernate]
Hibernate is an object-relational mapping (ORM) library for the Java language enabling developers to utilize POJO-style domain models in their applications in ways extending well beyond Object/Relational Mapping.
90,910
questions
2
votes
2
answers
18
views
Return empty collection when this collection is lazy intitialized
I have this object:
Entity
@Entity
public class someClass{
private String name;
private String labelKey;
@ManyToMany(cascade = {CascadeType.PERSIST,CascadeType.MERGE}, fetch = FetchType....
0
votes
0
answers
10
views
hibernate lock table before reading and deleting rows
I have a table which keeps getting updated. Every 30 seconds I read the values from these table to process something and then delete it. All is good, though I am worried that between reading and ...
0
votes
2
answers
26
views
java.lang.IllegalArgumentException: Invalid retrievedBook Id:1
While I trying delete Book entity with relations from database using this method
@Transactional
public void deleteBookById(Long id) {
List<BookStatus> bookStatuses = bookStatusService....
0
votes
1
answer
28
views
Spring JPA Parameter value [1000] did not match expected type [ma.mycom.myapp.domain.Client (n/a)]
I have two entities called Appointement and Client, and I would like to get all the
appointements of a given client. I am struggling with the following error message when I try to do so.
2022-05-24 ...
0
votes
0
answers
17
views
EntityMangerIssue Spring
I have this issue with my spring project
this is my entities for it and you can see the structure for them:
User Entity
package app.dbp.v1.entity.user;
import com.fasterxml.jackson.annotation....
0
votes
0
answers
18
views
Advices for implementing a timeseries table on a Mssql DB
I need advice to implement a timeseries table in MSSQL with a Spring Boot App.
Sorry guys I know MSSQL is not a timeseries DB but I have a requirement to use only MSSQL server. We have a project ...
-1
votes
0
answers
18
views
Getting only values instead of keys and values in JSON response in spring boot while calling Store procedure
@RestController
public class SpController {
@RequestMapping(value = "/getMicrosectorTiers", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ...
0
votes
0
answers
7
views
How to specifically ignore the hibernate quoted identifier attribute on a column in spring?
I have tables in postgres that all of them and their columns named with the doublequotes "". To make it easier, then I set the globally_quoted_identifier to true:
spring.jpa.properties....
0
votes
0
answers
21
views
Learning Hibernate and have such errors could not extract ResultSet и Table '...' doesn't exist?
Educational work - to create Entity on a DB.
And on the basis of a DB to collect one more column.
"Code a new LinkedPurchaseList table that populates based on the data in the PurchaseList table.&...
1
vote
1
answer
24
views
Spring JPA - Hibernate not adding columns to the table
I saw so many answers here, but couldn't find the one that could solve my problem.
problem: When I add the field in my entity class, hibernate does not update it in mysql automatically so I have to ...
0
votes
0
answers
6
views
Hibernate getNewSession, can see object non-commit changed value, why?
Session session = HibernateUtil.getCurrentSession();
ResAddr resAddr = resAddrHome.findById(1);
......
resAddr.setAddress(address);
resAddr.setStartDate(startDate);
resAddr.setDistrict(district); ...
0
votes
0
answers
16
views
ScrollableResults not initializing eager collections in Hibernate 5?
I've got an eagerly fetched one-to-many collection inside of an entity:
@OneToMany(fetch = FetchType.EAGER)
@Fetch(FetchMode.SUBSELECT)
@JoinColumns({
@JoinColumn(name="FK_COL_1", ...
0
votes
0
answers
11
views
EhCache is returning "Session is closed" after the upgrade version
We updated some libs recently such as the EhCache and Hibernate (from 4.2.1.Final to 5.4.32.Final)
After that, I notice an annoying error in the log:
2022-05-23 15:53:49.065 ERROR [my-data.data] ...
0
votes
0
answers
14
views
org.hibernate.WrongClassException: Object [id=1] was not of the specified subclass ... loaded object was of wrong class
I have two child classes extending a base class utilizing the joined inheritance type. When I retrieve an object that contains both and attempt to access them I hit a WrongClassException when ...
0
votes
1
answer
41
views
How can I get the client database settings automatically?
I've been working on a project lately and everything is fine until I try to send to project to someone.
So I have a hibernate.properties file that looks like this:
hibernate.dialect=org.hibernate....
-2
votes
0
answers
14
views
What is the Hibernate support cycle?
I am currently in the process of exchanging ehcache for infinispan in a hibernate project. This has lead to a number of interesting discoveries.
First of all, the hibernate-infinispan bridge is only ...
0
votes
0
answers
38
views
Hibernate join one to many by java
I'm using Hibernate and I have two tables:
Table A:
@Table(name = "users")
public class User extends BaseEntity {
@OneToMany(fetch = FetchType.LAZY, cascade=CascadeType.ALL)
@JoinColumn(...
0
votes
0
answers
22
views
Return type from JpaRepository depends on Discriminator column
I have a Spring Boot project and few entities based on "InheritanceType.SINGLE_TABLE".
Is it possible to return data type from JpaRepository depends on Discriminator column? Now I get the ...
0
votes
0
answers
34
views
Error of "Duplicate entry '14' for key 'dishes.PRIMARY'" When saving a value in DB via Json file
I have a problem saving a row in the "Orders" table. Each order includes a list of dishes.
When I saved through the code everything was fine. But when I send a JSON file, I see that Spring ...
0
votes
0
answers
20
views
Hibernate update setting JoinColumns as null in referenced table for OneToMany
I'm facing an issue where I'm trying to update TableA entity and Hibernate is executing updates on referenced table alongside. It tries to set null for the columns referenced in JoinColumn
I thought ...
0
votes
1
answer
21
views
Migration to Hibernate 6
I'm trying to migration my project to Hibernante 6 but I face some problems...
"type" attribute of @Type annotation is not recognized : @Type(type
= "yes_no")
Problem to ...
0
votes
1
answer
34
views
request.getAttribute("user") returning null object
I am trying to send object of User class to success.jsp. But getting null when trying to retrieve the object in success.jsp.
Code for UserController:
@Controller
@RequestMapping("/user")
...
0
votes
0
answers
27
views
How to INSERT IGNORE using JPA + Hibernate?
I have a simple entity,
@Entity
@IdClass(Key.class)
class TollEntry {
@Id
long vehicleId;
@Id
String tollId;
Instant timestamp;
//Other fields
}
class Key {
long vehicleId;
String ...
-1
votes
0
answers
19
views
Hibernate's default-update-timestamps-region.data causes 90% disk I/0
There was a huge disk I/O on our servers when we were doing some batch email processing (Spring Thread Pool Executor) by retrieving/updating data in DB. When I did a "sudo iotop" command I ...
-1
votes
0
answers
20
views
Bi-directional Stack over issue
public class Post {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private long postid;
@Column(nullable = false)
private String content;
@CreationTimestamp
...
0
votes
0
answers
29
views
Why make extra id column as primary key when look up will be using differnt column?
So, I've been leaning sql and database stuff recently as well as hibernate. I'm working on a hibernate project with some tables:
Player(int id, varchar username, varchar name) where id is pk and both ...
0
votes
0
answers
20
views
Get query string from data jpa for debug
I have usually JpaRepository.
There are several types of queries in it.
made with
JPA
JPQL
HQL
It occurred to me to see if they were doing unnecessary actions. I have enabled SQL query debug. ...
-1
votes
0
answers
18
views
tomcat connection interrupted with oracle database inside the DMZ
I am developing an application with spring boot, running on tomcat 9.
The oracle database is inside the DMZ .
the connection will be interrupted by the firewall after a while.
Is there a solution that ...
-2
votes
0
answers
15
views
Spring transaction not saving data from try/catch block
Can you explain why some error is not being saved to database even if it is in the catch block?
@Transactional
public void testTransaction() {
try {
repository.saveSuccess(...); //---> rolled ...
1
vote
0
answers
16
views
remove cart items from cart on finalization of shopping transaction
the question to you dear experts is how I need to delete cart items when finalizing shopping. What I know is that I should not delete cart but only items in it. Therefore how to delete cart items when ...
-1
votes
4
answers
50
views
spring boot not returning an object based on id
I am trying to find a particular country by id but I am getting an error when I test it on postman. I am new to spring boot and I have found out that the country id is being represented as a bigint ...
0
votes
0
answers
7
views
getting driver manager connection error while tying to connect mysql using hibernate
enter image description here
How can I resolve driver manager connection error
0
votes
2
answers
31
views
NullPointerException and OneToMany Eager Fetch
In a Service I want to set the betrag for a BudgetGeschaeftfeld.
After setting the Betrag, a method of budgetPlan which is Fetch.Eager should be called to update its own Betrag. However I get a ...
0
votes
0
answers
28
views
Updating generated columns using Java Spring
I have a view w/ cascade check option so it can be updated.
When I create a new object I want the read only columns of the view to be auto-populated. However hibernate seems to try to optimize for me ...
0
votes
0
answers
31
views
StackOverflowError - mappedBy
I have an entity account that I would like to link with another entity account.
When testing with postman I get a StackOverflowError because the list of friends is reloaded to infinity
What can I do ...
0
votes
1
answer
50
views
detached entity issue when updating entity spring jpa
I've looked at a bunch of answers to similar questions and I haven't found one that solves the issue for me. I feel completely lost right now.
I'm developping a Spring Boot web app, using Spring Data ...
0
votes
1
answer
23
views
Update list of entities transactional method
Will all the cars be black (in the database) after leaving the method?
@Transactional
public void test() {
List<Car> cars = carDao.findAll();
cars.forEach(car -> car.setColor("...
1
vote
1
answer
44
views
Why doesn't HikariCP establish a new connection to database after the previous one is closed?
To better understand how HikariCP works I decided to make a Spring Boot project to do some database data manipulation tests with a reduced wait_timeout in the database. Here are the HikariCP ...
0
votes
0
answers
15
views
Retrieve new entity (not proxied) inside a transaction in java
Retrieve NEW (not proxied) entity inside a transaction in Java with Hibernate
In java, it's possible to retrieve a new instance of a specific entity without retrieving the ones that hibernate proxies ?...
0
votes
1
answer
25
views
What is the difference between liquibase and Hibernate?
How can I use both in same SpringBoot project? Will it not create conflict which one is going to create tables?
0
votes
1
answer
58
views
+50
Hibernate fails to validate in-memory h2 database after flyway migration using Spring-Boot
Hibernate fails to validate database schema, which is created by flyway migration. (database migration script is correct) Is this because of in-memory H2 database? It almost looks like hibernate ...
0
votes
0
answers
43
views
getting error Connection oracle.jdbc.driver.T4CConnection@1f193686 marked as broken because of SQLSTATE(08006), ErrorCode(17002)
**> I am getting exception after upgrading oracle11g to oracle19C, using hikari as connection pool and hibernate and spring boot. Please
help.
When using IN query with lower number of ...
0
votes
0
answers
28
views
Spring Data/Hibernate/JPA join by non-primary keys
There are two related entities Account and AccountInfo. These entities connected by non-primary keys (number_ff, number_ff2). I see that Hibernate fetching three entities(Account, AccountInfo, ...
0
votes
2
answers
33
views
Spring, catch exception
I have small problem. I can't catch exception in method. I need to catch ConstraintViolationException to process it. Somebody know why it happens?
@Transactional(rollbackFor = Exception.class)
public ...
0
votes
1
answer
21
views
How can I use an alias with HAVING clause?
I'm trying to JPQL equivalent to the following SQL.
SELECT last_name, COUNT(1) AS c
FROM actor
GROUP BY last_name
HAVING c > 1
ORDER BY c DESC
I tried with the following JPQL.
SELECT e.lastName, ...
1
vote
0
answers
41
views
"org.springframework.dao.DataIntegrityViolationException: could not execute statement; SQL [n/a]; constraint [null];
i am traying to save a data in my data basewith a postmethod but i dont know why he said that one of my value is null (is_in_a_warehouse).
Is my json the problem ?
If i delete the "boolean not ...
0
votes
1
answer
31
views
JpaSystemException: ids for this class must be manually assigned before calling save()
I've been trying to create a new Student field that could be added into my MySQL database.
I'm using Spring Boot, MySQL Workbench and from my understanding everything is just as it should be - yet - ...
0
votes
0
answers
13
views
Persistence annotation requires a single-arg method LocalContainerEntityManagerFactoryBean
I have the below class, when i migrated to spring boot 2.7 i get this error
Caused by: java.lang.IllegalStateException: Persistence annotation
requires a single-arg method: public
org.springframework....
0
votes
2
answers
54
views
Using @ManyToOne how to map my one User to Cars?
I am trying to map owner(User) with an offer(car) whenever user is adding an offer. With setup like below user_id is always null. What am i missing ? I think it's something with controller. Mappings ...
0
votes
1
answer
51
views
How to take data from crosstabs from Database related ManyToMany relationship using Spring Boot / Thymeleaf
There are two tables Books and Users. They are connected by a many-to-many relationship and have a crosstab between them with columns book_id, reader_id, start date, and end date. I need to take data ...