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
2 answers

Spring @Transactional in an Aspect (AOP)

I've created an Aspect which contains an @Transactional annotation. My advice is being invoked as expected, but the new entity AuditRecord is never saved to the database, it looks like my @Transactional annotation is not…
levacjeep
  • 673
  • 3
  • 6
  • 23
18
votes
5 answers

No Query defined for that name, when using Entity Manager

I have the following entity: package com.server.models; @Entity @Table(name="users") @NamedQueries({ @NamedQuery(name=User.QUERY_FIND_USER,query="SELECT c FROM user c WHERE c.username = :username") }) public class User { public static final…
mangusbrother
  • 3,988
  • 11
  • 51
  • 103
18
votes
1 answer

Hibernate - hibernate.hbm2ddl.auto = validate

I am interested in how hibernate.hbm2ddl.auto=validate actually works and I am struggling to find comprehensive documentation. We've recently discovered production system was affected by…
azp74
  • 1,841
  • 2
  • 17
  • 23
18
votes
2 answers

Spring transaction boundary and DB connection holding

I am using spring boot and hibernate over jpa with tomcat connection pooling. Can you please help me understanding how spring uses DB connections during transactions. For example consider following scenario: We have DB connection pool of 2…
amique
  • 2,176
  • 7
  • 34
  • 53
18
votes
4 answers

Hibernate: Dirty Checking and Only Update of Dirty Attributes?

In the "good old JDBC days" I wrote a lot of SQL code that did very targeted updates of only the "attributes/members" that were actually changed: For example, consider an object with the following members: public String name; public String…
jens
  • 269
  • 1
  • 4
  • 6
18
votes
4 answers

What are the best workarounds for known problems with Hibernate's schema validation of floating point columns when using Oracle 10g?

I have several Java classes with double fields that I am persisting via Hibernate. For example, I have @Entity public class Node ... private double value; When Hibernate's org.hibernate.dialect.Oracle10gDialect creates the DDL for the Node…
Jason Novak
  • 1,081
  • 3
  • 13
  • 26
18
votes
12 answers

Hibernate schema parameter doesn't work in @SequenceGenerator annotation

I have the following code: @Entity @Table(name = "my_table", schema = "my_schema") @SequenceGenerator(name = "my_table_id_seq", sequenceName = "my_table_id_seq", schema = "my_schema") public class MyClass { @Id …
tabdulin
  • 353
  • 2
  • 4
  • 14
18
votes
5 answers

ORM solutions (JPA; Hibernate) vs. JDBC

I need to be able to insert/update objects at a consistent rate of at least 8000 objects every 5 seconds in an in-memory HSQL database. I have done some comparison performance testing between Spring/Hibernate/JPA and pure JDBC. I have found a…
mainstringargs
  • 13,563
  • 35
  • 109
  • 174
18
votes
6 answers

Exception java.lang.ClassNotFoundException: org.apache.commons.dbcp.BasicDataSource

I'm trying to integrate spring and Hibernate with mysql. I created a simple java project and a package with 3 classes, an application context.xml file, and an hbm.xml for mapping. But after executing, I get this error: Error: Sep 17, 2014 1:27:49…
megha
  • 189
  • 2
  • 2
  • 4
18
votes
5 answers

Foreign key not stored in child entity (one-to-many)

I'm quite new to hibernate and have stumbled on this problem, which I can't find solution for. When persisting parent object (with one-to-many relationship with child), the foreign-key to this parent is not stored in child's table. My…
Kamil Łoś
  • 218
  • 1
  • 2
  • 6
18
votes
3 answers

Understanding @BatchSize in Hibernate

The Hibernate documentation gives some information at @BatchSize as : @BatchSize specifies a "batch size" for fetching instances of this class by identifier. Not yet loaded instances are loaded batch-size at a time (default 1). I am not clear…
Chaitanya
  • 15,403
  • 35
  • 96
  • 137
18
votes
4 answers

How to declare repositories based on entity interfaces?

In a new project we would like to use Spring Data JPA and define interfaces for all JPA entities, e.g. like this: public interface Person extends Serializable { void setId(Long id); Long getId(); void setLastName(String lastName); String…
Didier L
  • 18,905
  • 10
  • 61
  • 103
18
votes
1 answer

Understanding Hibernate hibernate.max_fetch_depth and hibernate.default_batch_fetch_size

The Hibernate documenation gives some of the Hibernate configuration properties. Among them, hibernate.max_fetch_depth Sets a maximum "depth" for the outer join fetch tree for single-ended associations (one-to-one, many-to-one). A 0 disables…
Chaitanya
  • 15,403
  • 35
  • 96
  • 137
18
votes
2 answers

native insert query in hibernate + spring data

I try to add the following code to a spring data jpa repository: @Query("insert into commit_activity_link (commit_id, activity_id) VALUES (?1, ?2)") void insertLinkToActivity(long commitId, long activityId); But an app can't start with the…
mishka
  • 2,027
  • 2
  • 20
  • 30
18
votes
4 answers

JPA Composite Key + Sequence

Is it possible in plain JPA or JPA+Hibernate extensions to declare a composite key, where an element of the composite key is a sequence? This is my composite class: @Embeddable public class IntegrationEJBPk implements Serializable { //... …
Miguel Ping
  • 18,082
  • 23
  • 88
  • 136
1 2 3
99
100