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 is the umbrella for a collection of , most notably Hibernate ORM which provides Object/Relational Mapping for domain objects.
In addition to its own "native" API, Hibernate ORM is also an implementation of the Java Persistence API () specification.

Related tags

Beginner's resources

Frequently asked questions

People often ask the following questions:

94278 questions
19
votes
1 answer

How Do I Create Many to Many Hibernate Mapping for Additional Property from the Join Table?

I need a many to many hibernate mapping needed 3 joins. I've tried to find out a solution without intermediate entity like LecturerCourse. I have a many to many relation in my database between my lecturer and course tables. A course can be given by…
erencan
  • 3,725
  • 5
  • 32
  • 50
18
votes
1 answer

Embeddable entity with @OneToMany attribute

Say, I have following entities: @Entity public class A { @Id @GeneratedValue private Long id; @Embedded private B b; //getters and setters } @Embeddable public class B { @OneToMany private List cList; //getters and…
jFrenetic
  • 5,384
  • 5
  • 42
  • 67
18
votes
1 answer

Using Projections in JPA 2

I need to convert a Hibernate criteria query like the following curList = session.createCriteria(Islem.class) .createAlias("workingDay", "d") .setProjection(Projections.sum("amount")) …
Skyhan
  • 871
  • 3
  • 15
  • 26
18
votes
7 answers

Java Oracle exception - "maximum number of expressions in a list is 1000"

I am passing a list of Strings to my query(SQL query written) to fetch the required data. But I am getting this exception: ora-01795 maximum number of expressions in a list is 1000 I checked that I have more than 1000 entries in the list passed…
Anand
  • 20,708
  • 48
  • 131
  • 198
18
votes
3 answers

Advantages of using Hibernate Callback?

I am not able to understand advantages of using Hibernate Callback method, are there any advantages or specific use case where we should go for it. public List findRecentRequests(final int offset, final int length) { List list =…
Rachel
  • 100,387
  • 116
  • 269
  • 365
18
votes
14 answers

No Session found for current thread (Spring 3.1.X and Hibernate 4)

I'm trying to set up my project using Spring 3.1 and Hibernate 4. I've been following some tutorials online. I'm getting a strange error that according to the spring forums should have been fixed with Spring 3.1. Spring Bug Tracker When my…
It Grunt
  • 3,300
  • 3
  • 21
  • 35
18
votes
3 answers

How to create database schema in hibernate first time and further update it in case of schema modification?

I want to create database schema in hibernate first time. And further, if there is any modification in the schema, like addition of a new table or deletion of some column, I want to update the existing schema keeping the previous data intact. As per…
M Sach
  • 33,416
  • 76
  • 221
  • 314
18
votes
7 answers

How can I extend Java code generated by JAXB, CXF or Hibernate tools?

With generated Java source code, like code generated with Hibernate tools code generated with JAXB schema binding (xjc) code generated with WDSL2Java (cxf) all generated classes are "value object" types, without business logic. And if I add…
mjn
  • 36,362
  • 28
  • 176
  • 378
18
votes
4 answers

JPA/Hibernate: @ManyToOne and @OneToOne relationships tagged as FetchType.LAZY and optional = false not loading lazily on em.find()?

I have the following entity (only relevant mappings shown): @Entity @Table(name = "PQs") public class PQ implements Serializable { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column private Integer id; @Column …
Kawu
  • 13,647
  • 34
  • 123
  • 195
18
votes
3 answers

EhCache + Hibernate Cache is not alive

After configuring EhCache v2.4.5 as the second level cache for hibernate v3.6.7 I get the following error while trying to load all objects of a particular entity using hibernate session. (There is no error for loading the objects for the first…
Saffar
  • 520
  • 1
  • 5
  • 13
18
votes
7 answers

How to map PostgreSQL enum with JPA and Hibernate

I am trying to map a PostgreSQL custom type,named transmission_result, to a Hibernate/JPA POJO. The PostgreSQL custom type is more or less an enum type of string values. I have created a custom EnumUserType called PGEnumUserType as well as an enum…
vikash dat
  • 1,494
  • 2
  • 19
  • 37
18
votes
4 answers

Hibernate, alter identifier/primary key

I receive the following exception when I'm trying to alter my @ID in an @Entity. identifier of an instance of com.google.search.pagerank.ItemEntity was altered from 1 to 2. I know that I'm altering the primary key in my table. I'm using…
anon
18
votes
3 answers

What should I replace the hibernate deprecated @TypeDef and @Type annotations by?

I've just upgraded the version I use for Hibernate to 5.6.1 and it seems it's now deprecating some Type-related annotations: @TypeDef(name = "json", typeClass = JsonBinaryType::class) @Type(type = "json") I found no documentation as to what to do…
Crystark
  • 3,693
  • 5
  • 40
  • 61
18
votes
4 answers

"No Persistence Unit Found" error

I am getting the following error: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.transaction.interceptor.TransactionAttributeSourceAdvisor': Cannot create inner bean '(inner bean)' while…
John Roberts
  • 5,885
  • 21
  • 70
  • 124
18
votes
1 answer

Hibernate new keyword with distinct

I need to take hql that is currently : select distinct a from Asset as a where ... and change it to select new com.org.AssetDTO(a.id, a.address, a.status) from Asset as a where ... My problem is with the distinct keyword. Where does it belong in…
dstarh
  • 4,976
  • 5
  • 36
  • 68