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.

0
votes
0answers
24 views

Using Optional for getSingleResult

Hello I have a question about Optional. Optional should be used when there is possibility then null can be returned. I wanted to use it to find the image by item id. So in DAO: @Override public ...
0
votes
0answers
9 views

How to override transaction isolation in Spring with WebSphere and DB2

Best way to override transaction isolation in spring with WebSphere and DB2 Hi All, It seems that WebSphere doesn't let Spring to programmatically override transaction isolation level which is ...
0
votes
0answers
7 views

StoredProcedureQuery getResultList() does not return the data keys (column headers)

I am trying to get results from stored procedures on a Oracle database. These procedures are part of packages on the database, so I don't have visibility to the implementation of these procedures. So ...
0
votes
1answer
17 views

JPA/Hibernate One To One Extra Columns

I have 2 tables, PERSON and WORKPLACE, which relationship is one to one. I need a 3rd table with name PERSON_WORKPLACE where to join the 2 tables mentioned before. The structure must be the following:...
0
votes
0answers
10 views

How to fetch entities multiple levels deep with Hibernate

I'm trying to optimize my code by reducing queries by fetching deep associations in a single query. I looked everywhere and found this guide https://vladmihalcea.com/hibernate-facts-multi-level-...
0
votes
1answer
9 views

Foreign key constraint when deleting entity with many to many relationship

I have two entities: @Data @Entity @Table(name ="tags") public static class Tag { public abstract class BaseEntity extends AutoUpdatable { @Id @Column(unique = true, nullable ...
0
votes
1answer
22 views

Getting list of questions that has not been shown or answered

I have two tables : Question table where contains : And then I have another table that is called UserAnswerQuestion that contains : That has reference to the question via question_id The ...
0
votes
0answers
20 views

hibernate session save method not working?

I 'm new in spring and hibernate. i have a sample project that not work properly. when i try to save new order from user, i get no error or exceprion, but record not inserted into database. here my ...
0
votes
0answers
18 views

How to update the mapping table

I am trying to do a mini-project where there is a scenario where people can add incidence and others can comment on it.But the problem is when i try to comment on a incident the old comment is getting ...
0
votes
0answers
15 views

HibernateTemplate cannot write data to mysql

I change the flushMode to auto in the web.xml.but while i use HibernateTemplate to save the user to mysql,eclipse shows exception.but if i use SessionFactory and session.save() ,it success. 严重: ...
0
votes
0answers
6 views

Using spring security “principal” object in hibernate @Where annotation

I would like to make use of spring-security principal object to be able to filter down the lists that is going to be presented to the currently logged in user; let's say my current user has role to ...
0
votes
0answers
7 views

How Datasource Connection Pooling works in Hibernate Multi-tenancy with multiple client data stored in different schema on single DB instance?

Product that I work on have a single MSSQL database instance and inside that we have separate schema for each client. All these schemas share same table structure. We are using hibernate multi-tenancy....
0
votes
0answers
22 views

how to fix hibernate exception - Don't change the reference to a collection with delete-orphan enabled

I am trying to do a simple project which crawls the data from online shopping site using web driver, set those values to the entity and saves that entity called "product" to the database. Hibernate ...
0
votes
0answers
20 views

Hibernate disable SelectBeforeUpdate if without a generated Id

I found that if the entity mapping without a hibernate generated primary key value, the SelectBeforeUpdate(false) will not working. @Entity @SelectBeforeUpdate(false) class X { protected X(){} ...
0
votes
1answer
36 views

returning a list of instances by the foreign key

I have two models, Owner and Contract. A contract has an instance of an owner, owner does not have a list of contracts. I'm trying to query my list of contracts, to return a list filtered by owner, ie,...
0
votes
1answer
27 views

how do I use 3rd party Api for example this website(https://haveibeenpwned.com/API/v2) into my java code

I want to use api of https://haveibeenpwned.com/API/v2 website into my java code. what should I do ? what are the steps and if possible explain me with the help of code.
0
votes
1answer
47 views

How to fix ''null value in column “id” violates not-null constraint''

I'm created spring mvc project ,and i want to added model class in to DB(postgres v10) with Hibernate(v5) but when execute program, show error "null value in column "id" violates not-null constraint" ...
0
votes
1answer
16 views

Map SQL text array to Java String List in Spring data JPA

I have a text array as user_roles in my PostgreSQL database. I created a List<String> userRoles in my Entity. But Could not determine type for: java.util.List error appears. It works when I ...
0
votes
1answer
18 views

How to map OneToOne recursion entities?

I'm looking for how to solve a recursion and bidiretional onetoone relationship in my Branch object: @Entity @Table("BRANCH") public class Branch { @Id @GeneratedValue(strategy = GenerationType....
0
votes
0answers
19 views

Cannot load connection class because of underlying exception: com.mysql.cj.exceptions.WrongArgumentException

Here is my code: import java.sql.Connection; import java.sql.DriverManager; public class TestJdbc { public static void main(String[] args) { String jdbcUrl ="jdbc:mysql://localhost:...
1
vote
1answer
25 views

“MultipleBagFetchException: cannot simultaneously fetch multiple bags” when joining three depth table

org.springframework.dao.InvalidDataAccessApiUsageException: org.hibernate.loader.MultipleBagFetchException: cannot simultaneously fetch multiple bags: [Order.items, OrderItem.options]; Above is ...
-1
votes
1answer
37 views

Deleting entity in Spring JPA

There are two entities with relation @ManyToOne and @OneToMany (Categories and Products). When I enabeling (cascade=CascadeType.ALL) one record in Products pulls for deleting one Category, and that is ...
0
votes
0answers
23 views

java.lang.ClassCastException in hibernate while calling session.getUniqueResult or session.get

Class cast exception while calling session.getUniqueResult. I have tried with session.get but ended in the same error. Any help would appreciated From Logs java.lang.ClassCastException: com....
0
votes
0answers
26 views

Hibernate & MSSQL entities: How to properly map aggregated results

To sketch the context: I am refactoring this app that has performance issues because it has a lot of aggregated values. Currently the results were implemented as computed values inside columns (https:...
0
votes
2answers
32 views

Spring boot api how to prevent duplicate data creation

I have a POST API to create an entity called Person, and I check if person with the name and address exist or not, if not i create a person entity: class Person { UUID id String name; ...
-1
votes
0answers
10 views

hibernate.cfg.xml property requires additional setting to work properly ? what do those setting do?

My current hibernate.cfg.xml contains following property settings to work properly: <?xml version='1.0' encoding='utf-8'?> <property name="connection.driver_class">com.mysql.jdbc....
0
votes
1answer
34 views

How to solve Arabic value problem in Hibernate query

When I use an Arabic value in an HQL query, it returns null. I added the unicode and UTF in MySQL datasource. I got SQL generated from the Hibernate query and ran it in workbench, and it gave me a ...
0
votes
0answers
12 views

DirectPropertyAccessor removed in hibernate 5.1 and above, alternative?

I am upgrading my hibernate version in project from 3.6.10 to 5.4.1 I was using BasicPropertyAccessor and DirectPropertyAccessor for getter and setter methods as below in 3.6.10-: public class ...
0
votes
0answers
25 views

JPQL and list of tuples as parameter for SELECT IN statements

Given the following table layout: CREATE TABLE things ( id BIGINT PRIMARY KEY NOT NULL, foo BIGINT NOT NULL, bar BIGINT NOT NULL ); An entity class (Kotlin): @Entity @Table(...
0
votes
2answers
34 views

JPA ManyToMany - Always create a new value in the table even if the value exists

I'm going trough some trouble. I am coding the back-end of a website in spring and I am using a Rest API. I created two classes that are the relation "ManyToMany". The first class is "StateOfArt" and ...
0
votes
1answer
14 views

What is a connection checkout in Hibernate c3p0?

I am looking at the documentation of c3p0 where they have coined the term connection checkout, can someone explain what it means?
0
votes
0answers
15 views

Call to refresh not targeting database

A method (in a Stateless) searches for an object based on its identifier. This method calls another method (in another Stateless) in a new transaction. This new method searches the object based on its ...
0
votes
1answer
31 views

How to fix deployment error on Tomcat 9 - java.lang.IllegalArgumentException in Java Dynamic Web Project?

I have deployed my Spring Hibernate project on the VPS and then I am trying to run it, I am facing the issue: java.lang.IllegalArgumentException: More than one fragment with the name [spring_web] ...
0
votes
0answers
18 views

Why I'm getting “lazyinitializationexception could not initialize” when using session.getcurrentsession but not with session.opensession?

Why I'm getting "lazyinitializationexception could not initialize no session" when using session.getcurrentsession but not with session.opensession? Below is my code: Service class: @Override @...
0
votes
0answers
32 views

Foreign key not saving in child table in a One-to-many relationship

I am developing an REST API application using spring boot and is struck up with the One to Many mapping while using mappedBy property. I have User class and Usermeata class, a user can have more than ...
0
votes
0answers
20 views

Hibernate model for implementing ticketing service

So, I am making an issue tracker system, where I have users who create an issue ticket and have developers or "handlers" who will get the ticket and solve them. These handlers are associated with ...
0
votes
0answers
17 views

Select key from jsonb postgreSQL using Hibernate Criteria query in Java

I am writing the criteria query to get results for jsonb in postgres.I can query the jsonb column through hibernate.I am unable to fetch jsonb specific keys.I am not able to find a way. I have tried ...
0
votes
1answer
28 views

PreUpdate called but child collection entity not stored

I have a Spring project that uses lombok and a JPA annotated class defined this way: @EqualsAndHashCode @AllArgsConstructor @NoArgsConstructor @Data @Entity(name ="workflow_step") @Inheritance(...
-1
votes
0answers
16 views

How to write Hit counter using jsp, spring controller, hibernate

Hit counter using jsp, spring controller, hibernate for main landing page.
1
vote
0answers
31 views

How to create a native query to join related tables using @Query annotation

I am trying to use the @Query annotation with native query to get information from the database which I intend to use on one of the pages of my web shop application. I tried searching for a similar ...
0
votes
0answers
9 views

Spring Boot and Hibernate: EntityManagerHolder cannot be cast to SessionHolder

java.lang.ClassCastException: org.springframework.orm.jpa.EntityManagerHolder cannot be cast to org.springframework.orm.hibernate5.SessionHolder I get this error when I try to run code below @...
0
votes
0answers
12 views

JPA Stored procedure trying to get an OUT however I have a SELECT

This is a rather long and complicated question. I've got two stored procedures that use file name and XML. The first stored procedure is working wonderfully. It passes a file name and XML to save into ...
0
votes
1answer
23 views

Hibernate: Mapping Multi-Rows with ElementCollection - Single table no Embeddable

Looking for a solution to map multiple student_id rows under the same class_id, here is the table which has 3 fields: integer id PRIMARY KEY integer class_id; integer student_id; The table can have ...
0
votes
2answers
37 views

Foreign key value is not getting saved in hibernate in Child table

I have master and child table in the MS sql server. I have a foreign key reference in the child table. But still association is not getting established, value is getting null. So I have 'Student' ...
0
votes
0answers
9 views

Spring Webflow - Problem with converter type

I recently update to spring sts 4 so I'm not sure if something there is causing this issue because I did not have this error before. I've made sure that that the user object being fetched from the ...
0
votes
0answers
8 views

Table-per-concrete-class Inheritance mapping and OneToMany

My application needs to support using registered users from another system. This mapping is fine, I can load and query from both tables: @Entity @Inheritance(strategy = InheritanceType....
0
votes
1answer
26 views

how can I use spring to deserialize a postgres jsonb column to a list of objects?

I have a list of domain objects being saved to a postgres jsonb column (hibernate/jackson). The save works as expected but I get a mapping exception when deserializing. It looks like jackson is trying ...
0
votes
0answers
7 views

Delete operation in afterTrasnactionCommit raises exception

I am running within the context of an afterTransactionCommit. I have a method, which is marked as @Transactional(propagation = REQUIRED). The method is using a JPA EntityManager to perform the delete ...
0
votes
0answers
14 views

Reducing OneToMany to OneToOne with Where clause

I have a table setup like this: public class SampleMetricAggregation { @Id @Column(name="SAMPLE_METRIC_AGGR_ID") protected Long id; @OneToOne(fetch=FetchType.LAZY, mappedBy="sampleMetricAggrId") @...
0
votes
1answer
24 views

How to set a criteria with child table

I need to have query like this: select * from TABLE where Source_KEY in (1,2); My Hibernate class is like this: @Entity @Table(name ="TABLE", schema ="SCH") public class Table { private Long ...

http://mssss.yulina-kosm.ru