Latest Questions tagged Hibernate

Browse all latest questions tagged Hibernate

101
Votes
Published 07 Sep, 2022
Java - How to filter a PostgreSQL array column with the JPA Criteria API?

I am using: Hibernate 4.3.5 Spring JPA 1.6.0 Javax Persistence API 2.1 The "refcodemailing" column is defined as an array of int: int[] My entity object: @Entity @Table public class CalendarEven...

38
Votes
Published 16 Sep, 2022
Java - Why @OneToMany does not work with inheritance in Hibernate

@Entity @Inheritance(strategy = InheritanceType.SINGLE_TABLE) public class Problem { @ManyToOne private Person person; } @Entity @DiscriminatorValue("UP") public class UglyProblem extends Pro...

85
Votes
Published 19 Sep, 2022
Java - Hibernate java.lang.ExceptionInInitializerError

I've been working through the Hibernate Tutorial provided by Netbeans but whenever I tried running the program I end up with a java.lang.ExceptionInInitializerError. Anyone have any ideas about what's...

99
Votes
Published 06 Sep, 2022
Java - How to set autogenerated Id manually?

I have an entity called Task and it has taskId field. Problem is I need to create/update some specific tasks and JPA autogenerator doesn't allow me to set taskId manually.(It overrides my taskId) Is...

35
Votes
Published 27 Aug, 2022
Java - bad value for type long: - Postgresql, Hibernate, Spring

I wanna store an entity(a String + an image) in PostgresQL using Spring MVC and Hibernate Here is my table. The image is supposed to be the type of oid. CREATE TABLE document ( name character varyi...

81
Votes
Published 04 Oct, 2022
Java - Hibernate - Column cannot be null

I'm doing a simple exercise to learn JPA. When I try to delete an entity of type User, which has a Collection of the other entity Score (annotated with @OneToMany) I get this error: java.sql.SQLInteg...

42
Votes
Published 08 Oct, 2022
Java - How to avoid join 'explosions' in JPA with Hibernate when fields from multiple tables are needed?

Let's say I have the following method in a JpaRepository: @EntityGraph(value = "Subject.allJoins", type = EntityGraphType.FETCH) @Query("select s from Subject s" + FIND_QUERY_WHERE) Page<S...

103
Votes
Published 25 Aug, 2022
Java - Unable to configure second level cache of hibernate-ehcache-4.3.5.Final.jar in Hibernate 5.1.0.Final

I'm trying to achieve second level cache in my Java EE project using Hibernate. My Hibernate version is 5.1.0.Final. I've created a table employee in my MySQL database. I've included hibernate-ehcache...

32
Votes
Published 17 Aug, 2022
Java - Spring Framework Collection was evicted

I have this error: 2020-11-16 22:36:09.313 ERROR 19428 --- [nio-8080-exec-5] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw...

85
Votes
Published 07 Sep, 2022
Java - why Hibernate criteria return empty list if I have data in my table?

I didn't understand why I am getting empty list from criteria, and I have data in my table. code where I'm getting List: hibernateSession_destination = HibernateUtilReports.INSTANCE.getSession();...

146
Votes
Published 24 Aug, 2022
Java - javax.validation.ValidationException: HV000183: Unable to load 'javax.el.ExpressionFactory'

I try to write very simple application with hibernate validator: my steps: add following dependency in pom.xml: <dependency> <groupId>org.hibernate</groupId> <artifactI...

38
Votes
Published 11 Oct, 2022
Java - Keep getting "java.lang.IllegalArgumentException: No query defined for that name" even though I have @NamedQuery with an appropriate name

I have Hibernate JPA application. I keep getting "java.lang.IllegalArgumentException: No query defined for that name [Singer.findAll]" in the function from DAO class, even though I defined the name in...

97
Votes
Published 15 Sep, 2022
Java - When and why JPA entities should implement the Serializable interface?

The question is in the title. Below I just described some of my thoughts and findings. When I had a very simple domain model (3 tables without any relations), all my entities did NOT implement the Ser...

98
Votes
Published 20 Aug, 2022
Java - @SpringBootTest Error creating bean with name 'requestMappingHandlerAdapter'

I'm having problems with spring boot. I got the error Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled. 2019-09-22 10:16:18.954 ERROR 13...

33
Votes
Published 13 Aug, 2022
Java - Hibernate validation annotation - validate that at least one field is not null

Is there a way to define a Hibernate validation rule using annotations as defined here, stating that at least one field shall be not null? This would be a hypothetical example (@OneFieldMustBeNotNull...