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
18
votes
3 answers

What's the difference between Hibernate and JPA?

Can someone put in perspective the difference between JPA and Hibernate. Or are these complementary concepts, to be used together?
bmw0128
  • 1,625
  • 6
  • 25
  • 31
18
votes
3 answers

ERROR: type "datetime" does not exist

I am trying to migrate my hibernate-based app from MySQL to Postgres, but there seems to be a problem with the date format In my entity I have @Entity @Table( name = "APP_USERS" ) public class User { @Id …
Jose Ospina
  • 2,097
  • 3
  • 26
  • 40
18
votes
3 answers

How to properly handle two threads updating the same row in a database

I have a thread called T1 for reading a flat file and parsing it. I need to create a new thread called T2 for parsing some part of this file and later this T2 thread would need to update the status of the original entity, which is also being parsed…
Gaurava Agarwal
  • 974
  • 1
  • 9
  • 32
18
votes
1 answer

What is the use of @Table annotation in JPA?

The whole point of using these annotations is to be independent of the database provider, and not to regenerate the JAR archive. If I hardcore the @Table (name = myDatabase.myTableName) I don't see the point of using hibernate in the first place.…
Emily
  • 511
  • 3
  • 11
  • 23
18
votes
3 answers

(1+N) selects with OnetoOne associations

Considering the following model: @Entity public class User { @Id @Column(name = "USER_ID") private Long userId; @Column(name = "FIRST_NAME") private String firstName; @Column(name = "LAST_NAME") private String…
David
  • 910
  • 1
  • 12
  • 22
18
votes
4 answers

Injecting fields via Spring into entities loaded by Hibernate

I am looking for a way to inject certain properties via Spring in a bean that is loaded from the DB by Hibernate. E.g. class Student { int id; //loaded from DB String name; //loaded from DB int injectedProperty; //Inject via Spring } Can I…
Aayush Puri
  • 1,789
  • 3
  • 15
  • 19
18
votes
6 answers

com.mchange.v2.resourcepool.CannotAcquireResourceException: A ResourcePool could not acquire a resource from its primary factory or source

I have MySQL under my Hibernate and I am also using c3p0-0.9.1 for connection pool. When running on my laptop (I mean locally) I have no errors. But when I deploy it on the server, I get this…
moien goli
  • 181
  • 1
  • 1
  • 3
18
votes
3 answers

Proper Hibernate id generator for postgres serial/bigserial column?

My PostgreSQL tables have id's of type bigserial, meaning they are generated at the time rows are inserted (and thus, the id column's value is not supplied in the INSERT statement). I'm having difficulty finding the proper value for the
Matt Huggins
  • 81,398
  • 36
  • 149
  • 218
18
votes
3 answers

Spring/Hibernate testing: Inserting test data after DDL creation

I have a Spring/Hibernate webapp that has some integration tests that run on an in-memory HSQL database. Hibernate takes this blank database and creates all of my test tables and constraints thanks to hbm2ddl=create. However, I have a new bean…
Brandon Yarbrough
  • 37,021
  • 23
  • 116
  • 145
18
votes
3 answers

java.lang.NoSuchMethodException: org.hibernate.validator.ClassValidator Seam weblogic 10.3

I have a big problem with Hibernate (use with seam) on weblogic 10.3. When I publish my application, I get this error: java.lang.NoSuchMethodException: org.hibernate.validator.ClassValidator.(java.lang.Class, java.util.ResourceBundle,…
Kiva
  • 9,193
  • 17
  • 62
  • 94
18
votes
4 answers

Not an managed type: class entity. & Spring Data

I'm working with spring data, i create config class with @Bean, @Entity and Main.java but when run project i get exception: Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name…
Bohdan Olehovich
  • 575
  • 2
  • 13
  • 26
18
votes
4 answers

StaleObjectstateException row was updated or deleted by

I am getting this exception in a controller of a web application based on spring framework using hibernate. I have tried many ways to counter this but could not resolve it. In the controller's method, handleRequestInternal, there are calls made to…
Saky
  • 354
  • 2
  • 5
  • 16
18
votes
1 answer

Spring Validation Exception : BindException

on submitting form to addUser controller exception occured SEVERE: Servlet.service() for servlet dispatcherServlet threw exception org.springframework.validation.BindException: org.springframework.validation.BeanPropertyBindingResult: 1 errors …
kartikag01
  • 1,539
  • 1
  • 18
  • 36
18
votes
8 answers

Hibernate constraint ConstraintViolationException. Is there an easy way to ignore duplicate entries?

Basically I've got the below schema and I'm inserting records if they don't exists. However when it comes to inserting a duplicate it throws and error as I would expect. My question is whether there is an easy way to make Hibernate to just ignore…
luxerama
  • 1,109
  • 2
  • 14
  • 31
18
votes
5 answers

Optional one-to-one mapping in Hibernate

How do I create an optional one-to-one mapping in the hibernate hbm file? For example, suppose that I have a User and a last_visited_page table. The user may or may not have a last_visited page. Here is my current one-to-one mapping in the hbm…
hibernate
  • 737
  • 2
  • 7
  • 7
1 2 3
99
100