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

Hibernate: findById vs getbyId

having this classes: User.java: @Entity @Setter @Getter @NoArgsConstructor public class User { @Id private int id; private String username; @OneToOne(cascade = CascadeType.ALL, fetch = FetchType.EAGER) private Address address; …
milanHrabos
  • 2,010
  • 3
  • 11
  • 45
18
votes
3 answers

Why is my converted column marked by JpaAttributeTypeInspection with the error message "'Basic' attribute type should not be a map"?

I was trying to store some JSON as a string in a column via JPA and Spring and was following a baeldung tutorial. My code like this: @Column @Convert(converter = MyEntityExtentionConverter.class) private Map
mephisto_mori
  • 303
  • 1
  • 3
  • 7
18
votes
1 answer

How to maintain the column order when creating a new table using hibernate?

This is my pojo annotated as entity @Entity @Table(name = "book", catalog = "book_db") public class Book { private Integer bookId; private String bookName; private String bookShortDesc; private String bookDesc; private String…
Sony
  • 351
  • 1
  • 4
  • 9
18
votes
4 answers

Do you like the Criteria api of JPA 2.0? Do you use it with framework?

I'm used to work with Criteria API in Hibernate, and just watched how the Criteria in JPA 2.0 work. What i like most in the Criteria of Hibernate is the ease we have to compose with Criterions. The JPA Criteria seems quite heavy for me, and not as…
Sebastien Lorber
  • 89,644
  • 67
  • 288
  • 419
18
votes
2 answers

Domain Driven Design - Domain model vs Hibernate Entity

Are Hibernate Entities the same as the domain models? See the following example. Method 1 - Domain model and Entity are same class. Domain model "is-an" entity @Entity @Table(name = "agent") class Agent { @Id @GeneratedValue(strategy =…
Vino
  • 2,111
  • 4
  • 22
  • 42
18
votes
11 answers

JPA Lazy loading is not working in Spring boot

I googled a lot and It is really bizarre that Spring Boot (latest version) may not have the lazy loading is not working. Below are pieces of my code: My resource: public ResponseEntity> searchAirWaybill(CriteraDto criteriaDto,…
Houssam Badri
  • 2,441
  • 3
  • 29
  • 60
18
votes
6 answers

Prevent Dozer from triggering Hibernate lazy loading

I am using Spring transactions so the transaction is still active when POJO to DTO conversion occurs. I would like to prevent Dozer from triggering lazy loading, so that hidden sql queries never occur : all fetching has to be done explicitly via HQL…
Tristan
  • 8,733
  • 7
  • 48
  • 96
18
votes
7 answers

Spring JPA - "java.lang.IllegalArgumentException: Projection type must be an interface!" (using native query)

I'm trying to retrieve a timestamp date from an oracle database but the code is throwing: java.lang.IllegalArgumentException: Projection type must be an interface! I'm trying to use native query because the original query is way to complex to…
Fábio Castilhos
  • 201
  • 1
  • 2
  • 8
18
votes
6 answers

How to remove unwanted entity from Hibernate session?

I'm trying to fetch Entity1 by querying on mapped entities to it. I'm using CriteriaBuilder to perform this as shown below CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder(); CriteriaQuery createQuery =…
dwayneJohn
  • 919
  • 1
  • 12
  • 30
18
votes
4 answers

how to check HikariCP connection pooling is working or not in Java?

I have written following properties in my configuration files I am using Log4j in my application When I am running a project. I am getting following message.does that mean connection pooling is configured in my project? if not then how it will…
Tejal
  • 764
  • 1
  • 10
  • 39
18
votes
2 answers

how to do a JOIN FETCH in jpa criteria

I am trying to translate the query below to criteria api. SELECT er from ereturn er JOIN FETCH product_item pi ON pi.ereturn_id = er.id WHERE pi.status = "RECEIVED" To something like this: CriteriaBuilder builder =…
masber
  • 2,875
  • 7
  • 29
  • 49
18
votes
4 answers

Storing UUID as string in mysql using JPA

I came across a blog of using UUID with Hibernate and MySql. Now the problem is, whenever I take a look at the database the ID's will be non-readable format (binary-16). How can I store UUID as a readable format like…
Sunil Rao
  • 800
  • 2
  • 6
  • 23
18
votes
2 answers

Benefits of using Springs Transaction management vs using hibernate

I've been trying to learn spring and hibernate, and I've used a lot of examples around the net to put together a nice application. However, I realized now that Spring supports transaction management. In my spring app I just simply made whatever…
Matthew Stopa
  • 3,793
  • 6
  • 42
  • 51
18
votes
2 answers

How is SQL injection typically stopped in a Spring/Hibernate setup

I hate the Ruby language because it's not statically typed but the more time I spend with Spring/Hibernate I appreciate more of Ruby on Rails' features. Specifically the fact that their Active Record model prevents SQL injection for you. How is this…
Matthew Stopa
  • 3,793
  • 6
  • 42
  • 51
18
votes
7 answers

LazyInitializationException with graphql-spring

I am currently in the middle of migrating my REST-Server to GraphQL (at least partly). Most of the work is done, but i stumbled upon this problem which i seem to be unable to solve: OneToMany relationships in a graphql query, with FetchType.LAZY. I…
puelo
  • 5,464
  • 2
  • 34
  • 62