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
172
votes
14 answers

Spring Boot + JPA : Column name annotation ignored

I have a Spring Boot application with dependency spring-boot-starter-data-jpa. My entity class has a column annotation with a column name. For example: @Column(name="TestName") private String testName; SQL generated by this created test_name as the…
Kamil
  • 2,158
  • 2
  • 18
  • 19
166
votes
4 answers

Difference between save and saveAndFlush in Spring data jpa

I am trying to learn spring data JPA by testing some CRUD operation via JpaRepository. I came across two methods save and saveAndFlush. I don't get the difference between these two. On calling save also my changes are getting saved into database so…
Anand
  • 20,708
  • 48
  • 131
  • 198
164
votes
23 answers

Hibernate error - QuerySyntaxException: users is not mapped [from users]

I'm trying to get a list of all the users from "users" table and I get the following error: org.hibernate.hql.internal.ast.QuerySyntaxException: users is not mapped [from…
Blue
  • 1,889
  • 4
  • 16
  • 16
164
votes
31 answers

Hibernate: "Field 'id' doesn't have a default value"

I'm facing what I think is a simple problem with Hibernate, but can't solve it (Hibernate forums being unreachable certainly doesn't help). I have a simple class I'd like to persist, but keep getting: SEVERE: Field 'id' doesn't have a default…
André Chalella
  • 13,788
  • 10
  • 54
  • 62
164
votes
6 answers

JpaRepository Not supported for DML operations [delete query]

I have written a query to delete some objects in my interface extending JPaRepository, but when I execute the query it throws an exception! Can anyone explain it for me? Query: public interface LimitRepository extends JpaRepository
Student
  • 1,643
  • 2
  • 8
  • 6
162
votes
4 answers

@Column(s) not allowed on a @ManyToOne property

I have a JPA entity with a property set as @ManyToOne @Column(name="LicenseeFK") private Licensee licensee; But when I deploy on JBoss 6 the application throws an error saying: org.hibernate.AnnotationException: @Column(s) not allowed on a…
newguy
  • 5,668
  • 12
  • 55
  • 95
161
votes
8 answers

Apache Commons equals/hashCode builder

I'm curious to know, what people here think about using org.apache.commons.lang.builder EqualsBuilder/HashCodeBuilder for implementing the equals/hashCode? Would it be a better practice than writing your own? Does it play well with Hibernate?…
aug70co
  • 3,965
  • 5
  • 30
  • 44
160
votes
23 answers

Hibernate JPA Sequence (non-Id)

Is it possible to use a DB sequence for some column that is not the identifier/is not part of a composite identifier? I'm using hibernate as jpa provider, and I have a table that has some columns that are generated values (using a sequence),…
Miguel Ping
  • 18,082
  • 23
  • 88
  • 136
155
votes
25 answers

Hibernate Annotations - Which is better, field or property access?

This question is somewhat related to Hibernate Annotation Placement Question. But I want to know which is better? Access via properties or access via fields? What are the advantages and disadvantages of each?
Martin OConnor
  • 3,583
  • 4
  • 25
  • 32
154
votes
11 answers

Another Repeated column in mapping for entity error

Despite all of the others post, I can't find a solution for this error with GlassFish, on MacOSX, NetBeans 7.2. Here the error : SEVERE: Exception while invoking class org.glassfish.persistence.jpa.JPADeployer prepare method SEVERE: Exception while…
canardman
  • 3,103
  • 6
  • 26
  • 28
150
votes
11 answers

How do I call the default deserializer from a custom deserializer in Jackson

I have a problem in my custom deserializer in Jackson. I want to access the default serializer to populate the object I am deserializing into. After the population I will do some custom things but first I want to deserialize the object with the…
Pablo Jomer
  • 9,870
  • 11
  • 54
  • 102
149
votes
4 answers

Default fetch type for one-to-one, many-to-one and one-to-many in Hibernate

What is the default fetch type in hibernate mappings? What I got to know after exploring is: for one-to-one it is eager. for one-to-many it is lazy. But after testing it in Eclipse, it was eager for all. Does it depend on whether I am using JPA or…
Richa
  • 7,419
  • 6
  • 25
  • 34
149
votes
17 answers

Ignore fields from Java object dynamically while sending as JSON from Spring MVC

I have model class like this, for hibernate @Entity @Table(name = "user", catalog = "userdb") @JsonIgnoreProperties(ignoreUnknown = true) public class User implements java.io.Serializable { private Integer userId; private String userName; …
iCode
  • 8,892
  • 21
  • 57
  • 91
149
votes
5 answers

Cannot create a database table named 'user' in PostgreSQL

It seems PostgreSQL does not allow to create a database table named 'user'. But MySQL will allow to create such a table. Is that because it is a key word? But Hibernate cannot identify any issue (even if we set the PostgreSQLDialect).
Channa
  • 4,963
  • 14
  • 65
  • 97
148
votes
6 answers

Hibernate, @SequenceGenerator and allocationSize

We all know the default behaviour of Hibernate when using @SequenceGenerator - it increases real database sequence by one, multiple this value by 50 (default allocationSize value) - and then uses this value as entity ID. This is incorrect behaviour…
G. Demecki
  • 10,145
  • 3
  • 58
  • 58