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.

hibernate
36,428 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
0 votes
2 answers
491 views

Setting default value in entity class is not working incase of OneToMany mapping

I have a csv file from where i will read the data and map it to corresponding java object using opencsv. I have my entity class like below @Data @Entity @Table(name="student_info") public ...
krishna's user avatar
  • 363
0 votes
0 answers
69 views

Foregine key is not updating in spring boot Jpa

Basically, I am trying to establish a relationship between my two tables using spring boots. And the relationship which I had used was the @onetoone and @onetomany relationship. But after building the ...
Shykat Roy NDUDUgCyEt's user avatar
0 votes
0 answers
781 views

Using @Transactional correctly in Spring boot for big queries

I have a method who calls 3 childs-methods before making a transaction with the repository, like this : import org.springframework.stereotype.Service; import org.springframework.transaction.annotation....
Greg's user avatar
  • 126
0 votes
1 answer
82 views

One to Many Bidirectional mapping for already persisted data in Hibernate

Im trying to update my parent class with already persisted children objects. @Entity public class Parent { @Id @GeneratedValue(strategy = GenerationType.AUTO) private Long id; @OneToMany(...
Nirojan Selvanathan's user avatar
0 votes
1 answer
77 views

How to fix typing in hibernate "findBy" for enums?

I have an entity like so public class SomeClass { @NonNull @NotNull @Column(nullable = false) @Convert(converter = SomeEnumConverter.class) private SomeEnum fieldName; } I want ...
Harsha Limaye's user avatar
0 votes
1 answer
282 views

hibernate and mysql and Operand should contain 2 column(s)

I am getting a couple of exceptions: First, org.hibernate.engine.jdbc.spi.SqlExceptionHelper - Operand should contain 2 column(s) Second, org.hibernate.exception.DataException: could not extract ...
Karl Ninh's user avatar
0 votes
0 answers
613 views

Connections could not be acquired from the underlying database + mysql + hibernate

I want to use Hibernate and mysql in Eclipse error: Caused by: java.sql.SQLException: Connections could not be acquired from the underlying database! at com.mchange.v2.sql.SqlUtils.toSQLException(...
Fattaneh Talebi's user avatar
0 votes
1 answer
152 views

JPA update a object creates a new one in a ManyToMany Relation

I'm having issues while trying to update objects with JPA. The problem instead of updating an existing object, it creates new ones along with new embedded data. Here is my java code: First entity @...
fab_95's user avatar
  • 1
0 votes
0 answers
63 views

How to store JSON type data in a MySql DB in Hibernate java

This is my field in domain class. @Entity @Table(name = "Field") public class Field implements Serializable { private static final long serialVersionUID = 1L; @Id ...
Mands's user avatar
  • 191
0 votes
0 answers
2k views

Spring boot change the IP address of server with my LAN IP

trying to use the IP address of LAN instead of the localhost domain name. I have added the property server.address in the application.properties file like in image: but this show me an error: 2021-08-...
3UMF's user avatar
  • 5,548
0 votes
0 answers
1k views

How to change the order of columns in a table?

I do not like the order of the columns in the database h2. I use Auditing to create tables. Example code package ru.omega.vaccination.model.dto.audit; import com.fasterxml.jackson.annotation....
WBLord's user avatar
  • 912
0 votes
0 answers
344 views

How to used Transient keyword in entity class according to condition?

I have Spring-Boot with Spring data project when I connect that to Person table in database 1 it is working perfectly. Now when I connect same codebase to Person table in database 2 where that table ...
Ganesh Java's user avatar
0 votes
1 answer
543 views

Why can't I create an EntityManager using JPA in my project?

I hope you are well, I am trying to create a simple project to learn Java and its standards. I have the following config file for persistence persistence.xml <?xml version="1.0" encoding=&...
Juan Fernando Huenchun's user avatar
0 votes
2 answers
765 views

Spring JPA - Query against id in a Set of sub entities

I am trying to figure out how I would go about querying against this type of data structure for all of the Animal objects that have a brownBearId; Using either a jpa repository method or @Query ...
duppydodah's user avatar
0 votes
0 answers
177 views

How to resolve JPA @PersistenceContext nullpointer exception

My appologies, i am fairly now to JPA and this may be a dumb user error, but... Here is my pom's dependency section: <dependencyManagement> <dependencies> <...
Bend's user avatar
  • 354
0 votes
1 answer
265 views

JPA CriteriaBuilder subquery?

I have a SQL statement like this: select * FROM T1 WHERE 0 = ( SELECT count(*) FROM T2 WHERE T2.T1ObjId = T1.ObjId AND T2.column = 'someText' ) And I'm trying to figure out how to write it using the ...
chama's user avatar
  • 6,053
0 votes
0 answers
67 views

query is working in workbench but not in hibernate

the Java code @Query(nativeQuery = true, value ="select account_id , GROUP_CONCAT(DISTINCT id SEPARATOR ',') AS location_id from locations ll where ll.parent_location in (SELECT id as building_id ...
SUDHIR KUMAR's user avatar
0 votes
0 answers
49 views

Application.restart() return null

I'm trying to restart spring boot application after executing an application. So I've added a context in the main class: @SpringBootApplication public class MainApplication { private static ...
Greg's user avatar
  • 126
0 votes
2 answers
77 views

How to show data to user with DTO

This is the data that I am currently showing to the user: { "id": 3, "name": "AB:11", "description": "AB:11 is an Imperial Black Barley Wine brewed ...
Filip Vidojevic's user avatar
0 votes
0 answers
520 views

hibernate ManyToOne ORM in java getting duplicate rows when persisting objects on the ONE side

I am using H2 database and hibernate and I want to apply ORM with a relation manytoone. my code: @Entity @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS) public abstract class ...
anonymous's user avatar
0 votes
1 answer
125 views

Spring boot not returning correct jsp, 404 page error

Hi there i'm fairly new to using the spring framework and im trying to create a webapp to display students from database but i cant seem to get my spring boot app to display the jsp pages i dont know ...
Alpheus's user avatar
  • 41
0 votes
0 answers
288 views

Out of memory error in quarkus hibernate panache

I am using quarkus with hibernate panache.. My entity has almost 105 attributes. I am following Panache Repository model. To retrieve values from database I have used list(query, param). I do have an &...
AVM's user avatar
  • 9
0 votes
1 answer
72 views

Problems with Hibernate Mapping

I'm having problem with mapping two classes with composite keys. The first class is Product: @Entity @Table(name = "Products") @Getter @Setter @AllArgsConstructor @NoArgsConstructor @...
Andres Ghione's user avatar
0 votes
1 answer
283 views

Hibernate ManyToMany remove other side if children empty

I have 2 entities with @ManyToMany relation. I want to delete Activity while deleting User, if users field gets empty. @Entity public class User { ... @ManyToMany(mappedBy="users") private ...
Ulphat's user avatar
  • 744
0 votes
1 answer
325 views

Hibernate 5 Association [] references an unmapped entity [] : origin(User.hbm.xml)

I'm STILL dealing with a non-Spring legacy application, with a matching legacy database that is not easily updateable, so I have to deal with the cards that were dealt me. I'm moving this non-Spring ...
tjholmes66's user avatar
  • 1,908
0 votes
1 answer
349 views

compatible spring core with hibernate 5.4

I am using hibernate 5.4.25 and spring 4.3.30 . Getting error as noclassdeffounderror for getFlushMode() . What is spring version to be used with hibernate 5.4.25?
Aakanksha Wankhede's user avatar
0 votes
0 answers
387 views

Converter's type UUID doesn't match with the attribute type Set<UUID>

I have the following JPA entity attribute with its annotations: @Convert(converter = UuidConverter.class) @ElementCollection @CollectionTable(name ="entity_branch", joinColumns=@JoinColumn(...
christopher.online's user avatar
0 votes
0 answers
52 views

How update table automatically with @DynamicUpdate and @Transactional

I would like to update a column entry automatically when the application start. To do that, I've a simple model with @DynamicUpdate anotation : @Entity @DynamicUpdate @EqualsAndHashCode public class ...
Greg's user avatar
  • 126
0 votes
1 answer
198 views

How can store only 10 rows in table

I have to fill database with maximum 10 rows, any ideas how to do that? I only know how to limit queries, but in this case I have to save maximum 10 rows to database
markz's user avatar
  • 5
0 votes
1 answer
486 views

Hibernate 5 Duplicate Mapping with Composite Key

I'm dealing with a non-Spring legacy application, with a matching legacy database that is not easily updateable, so I have to deal with the cards that were dealt me. I'm moving this non-Spring app ...
tjholmes66's user avatar
  • 1,908
0 votes
1 answer
40 views

HttpMessageNotWritableException vs MultipleBagFetchException

I'm coming back to you because I'm blocked. I'm currently facing a MultipleBagFetchException, please find bellow my Entity Expense. To resolve this mainly the solution can be to fetch Lazy and the ...
Erick Caron's user avatar
0 votes
0 answers
108 views

ORA - 01400 : Cannot Insert into null (One to Many bidrectional) JPA having Composite Keys

When I'm trying to save the child table, the insert query fired doesn't contain the foreign key field. The insert query that JPA fires doesn't contain the foreign key column. Here are the models and ...
retrx22's user avatar
  • 61
0 votes
2 answers
395 views

Hibernate - WrongClassException

This is part of the domain model of the music system I'm building: @Entity @Table(name="library_entities", schema="myschema") @Inheritance(strategy = InheritanceType.SINGLE_TABLE) @...
Amirhosein Al's user avatar
0 votes
1 answer
151 views

Hibernate: No query defined (no entity class)

There are some related questions like: Return custom object from Spring Data with Native Query No Query defined for that name, when using Entity Manager However, it get the error: No query defined ...
Thanthla's user avatar
  • 526
0 votes
1 answer
115 views

Joining unrelated Entities using JPQL not working in spring data with hibernate 5.3.2

I am not able to figure out what's wrong in following jpql query, which I am using in spring boot project with spring data and hibernate 5.3.2. select t from MdmVehicle t join MdmVehicleGateInOut g ...
Techie Manoj's user avatar
0 votes
0 answers
437 views

LIKE clause on Map key and value - querydsl

Is there a way to convert given query from @Query annotation to Query DSL? The idea is to search for countries by few first characters of name. While using Hibernate 5.5.6.Final, this query was fine, ...
horvoje's user avatar
  • 747
0 votes
0 answers
311 views

Springboot BindingResult hasErrors is always false

I have tried all the answer I have found on internet and nothing seems to be working. I have added hibernate-validation, spring validation but both are not working and bindingResult.haserrors() is ...
david's user avatar
  • 79
0 votes
1 answer
345 views

JPA Query not returning data while sending multiple values in request

I'm having issue finding null or empty list in my JPA Query. I was able to get the values for single and empty value selection via request. But, same this is not working if I pass multiple values. @...
TechGeek's user avatar
  • 498
0 votes
0 answers
68 views

What's the best way to make my java service run in a distributed environment, which uses Hibernate?

I have a gRPC java service which uses Hibernate for making database updates. The data ingestion part takes a long time, and I need to ingest even more data which would make it impossible to do it ...
charmander's user avatar
0 votes
1 answer
121 views

Unable to save an entity "a foreign key constraint fails "

I am trying to save an entity to a table which was created using the @JoinTable annotation. This is the main entity where the table is set: public class MachineGroup { @Id @GeneratedValue(...
Gilad Dahan's user avatar
0 votes
0 answers
79 views

Make errors recoverable with Spring JPA application

I have a simple Spring JPA application that initializes in the following way: Main.Class: import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure....
Felipe La Rotta's user avatar
0 votes
0 answers
168 views

'One To Many' attribute value type should not be ________ Error

I have 3 classes. The relationship between User, Image, and Album is a User can have many Images a User can have many Albums User class: public class User { @Id @GeneratedValue(strategy = ...
axnt0001's user avatar
0 votes
1 answer
123 views

Does EntityManager.getReference() matter if the entity is @Cached/@Cacheable?

Say I want to update entity A which references B but B is a big entity. If B is not a cached entity (2nd-level), I normally do a getReference() if I have access to B's PK to avoid the extra SELECT ...
Rey Libutan's user avatar
  • 5,276
0 votes
0 answers
307 views

How to return a custom message with @UniqueConstraint and @Column(unique = true)

I would be capable to return a custom message when a user send a data that already existis in database. There is my class: @Entity @Table(name="unity") @Data @Builder @AllArgsConstructor @...
Vitor Nilson's user avatar
0 votes
2 answers
84 views

Entity with oracle sequence as ID throws org.hibernate.PropertyAccessException

When I try to save my entity in my oracle db using the .save() method of the hibernate session I get this exception : org.hibernate.PropertyAccessException: Could not set field value [1757] value by ...
Gadou's user avatar
  • 59
0 votes
1 answer
1k views

Spring modelmapper map lazy loaded entities

I'm using modelmapper (http://modelmapper.org/) to map an entity with a lazy loaded list (by hibernate) of objects to a DTO with modelmapper.map(). The outcoming dto has a null value as list, although ...
lando's user avatar
  • 437
0 votes
0 answers
163 views

can we create two session factory of same database with different users in spring boot application

I am new to spring boot and I need to use same postgreSQL sql database with two different users in same package in same class please suggest me the ways which I can do to make it work in my ...
AnudeepYajamanyam's user avatar
0 votes
1 answer
126 views

Hibernate combine AND and OR query

I have the following hibernate query findByUserOrReaderAndIdInAndStatusNotIn the actual query generated is WHERE user=? OR reader=? AND (id in (?, ?)) AND (status not in (?, ?)) but what I actually ...
iPhoneJavaDev's user avatar
0 votes
0 answers
152 views

Workaround for Hibernate lazy initialisation not working

So I'm making a deep copy of an object using method here (serialise and deserialise). Before doing the clone, I'll need to initialise a List in the object so that the copy can have it. This is what I ...
wayne's user avatar
  • 668
0 votes
0 answers
665 views

How to resolve Maven dependency for Hibernate in NetBEans 12.4

I'm learning Hibernate. This is my day 1 and I'm watching this video on YouTube: Hibernate Tutorial | Practical. I did exactly what the tutor said but my program is not able to recognize: import org....
Tanzeel's user avatar
  • 4,602

1
336 337
338
339 340
729