r/hibernate • • Aug 06 '24

Top 50 Hibernate and JPA Interview Questions Answers for 3 to 5 Years Experienced Java developers

Thumbnail
javarevisited.blogspot.com
5 Upvotes

r/hibernate • • Aug 15 '23

JPA Query To SQL - IntelliJ Plugin

5 Upvotes

Hi,

Tired of manually converting JPA Queries to SQL, so I created a plugin that does this. Now I'm free from the burden of trying to convert 30-40 lines of single hibernate query to SQL so that I can execute it and check why it's failing in production(😢).

This only works if your Entities are annotated with `@Table` and Fields are annotated with `@Column`.

Link to Plugin: https://plugins.jetbrains.com/plugin/22023-jpql-to-sql

Code is available in github: https://github.com/manu156/jpqltosql

If you have any feature requests, please raise it on github. edit: support for HQL is rolling out


r/hibernate • • Aug 01 '24

Top 10 Hibernate Interview Questions and Answers for 3 to 5 Years Experienced Java Developers

Thumbnail
javarevisited.blogspot.com
4 Upvotes

r/hibernate • • May 06 '24

Share your thoughts on Hibernate support for MongoDB and enter a chance to win an Amazon gift card

4 Upvotes

Hi there!

We are Product Managers working on Database Experiences at MongoDB.

We curious to learn more about how you might be using Hibernate today, and if you would be interested in building MongoDB applications using Hibernate.

We value your time and input, so completion of this ~5 minute survey will automatically enter you into a raffle to win a $50 Amazon gift card.

This survey will close on May 17.

Google Form Survey: https://forms.gle/9mQ41wzJwEBoVVWv5


r/hibernate • • Mar 08 '19

Hibernate ORM running on Quarkus

4 Upvotes

Hello all,

I'm happy to report that Hibernate ORM can now work even when compiled as GraalVM native images - just make sure you use Quarkus to build the application.

This allows your applications to be extremely well optimised, to the point of booting in just about ~2 milliseconds and consuming less than a single megabyte of heap - the runtime container doesn't even need the JDK being installed.

There's a short video showing boot of a fully working REST server connecting to PosgreSQL over Hibernate here (or see the​ original asciicast version).

The very same demo can be run from the Quarkus quickstarts.

N.B. Quarkus is more more efficient than existing frameworks even in JVM mode - so not only for those interested in GraalVM - and comes with additional great improvements for JVM users, such as Live Reload: in this mode, try making any change to any class - including JPA entities! - and the whole app will be re-booted so fast that you won't even notice.

If you setup Hibernate to generate the schema, this implies that as soon as you save changes to your JPA entities the database is immediately up to date. You can play with mapping annotations and see the schema adapt in real time!

To learn more about Quarkus there's a "getting started"; for specific interests about Hibernate see "https://quarkus.io/guides/hibernate-orm-guide".

And to keep the best point last: we're also introducing the "Hibernate ORM - Panache" extensions, a new way of using Hibernate ORM, allowing to use your entities in a more powerful and fun way.


r/hibernate • • Jan 30 '17

How to implement a soft delete with Hibernate

Thumbnail
thoughts-on-java.org
4 Upvotes

r/hibernate • • Jan 04 '24

Migrating PostGIS to Hibernate 6

3 Upvotes

I'm trying to migrate to Spring Boot 3 (and hibernate-spatial:6.4.1.Final) So before migration i have following lines in my @Entity describing a column in the table storing a MultiLineString geometry:

@Column(name = "multilinestring")
@Type(value = "org.locationtech.jts.geom.MultiLineString")
private MultiLineString multiLineString;

Naively, I'm converting the @Type to @Type(org.locationtech.jts.geom.MultiLineString.class), but this gives an error, because MultiLineString doesn't extend UserType (incompatible types: Class<MultiLineString> cannot be converted to Class<? extends UserType<?>>)

So which class am I supposed to use in this case? Or what am I doing wrong?

Excerpt from my gradle file in case this matters:

plugins {
    id 'org.springframework.boot' version '3.2.1'
    id 'io.spring.dependency-management' version '1.1.4'
    id 'java'
}
repositories {
    mavenCentral()
}

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-web'
    implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
    implementation 'org.springframework.boot:spring-boot-starter-data-rest'
    implementation 'org.springframework.boot:spring-boot-starter-security'
    implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
    implementation 'org.springframework.boot:spring-boot-starter-mail'
    implementation 'org.springframework.boot:spring-boot-starter-validation'
    implementation 'org.hibernate.orm:hibernate-spatial:6.4.1.Final'
    implementation 'net.postgis:postgis-jdbc:2023.1.0'
    implementation 'org.thymeleaf.extras:thymeleaf-extras-springsecurity6'
    
    ....
}

r/hibernate • • Dec 09 '23

Hibernate-ORM usage research

3 Upvotes

Hey everyone,

I am currently in the process of developing an integration tool aimed at establishing a seamless connection between Hibernate-ORM and Atlas (think Terraform but for databases).

I'm trying to get a sense of how Hibernate is used in the wild. Looking for common patterns integration patterns, common build systems, and the initialization process of Hibernate and the entities.

For example:

  1. How is Hibernate initialized with which entities? (do you manually specify which entities to use via Metadata or do you use automatic scanners provided by frameworks such as Spring?)

  2. Are you overriding any default services?

  3. Do you use Spring?

  4. Do you use the same code base for multiple databases or multiple schemas? How do you manage that?

  5. How do you currently deal with database migrations?

Appreciate your input on these, thanks!


r/hibernate • • Sep 17 '22

Persism 2.2.0 - A Lightweight ORM for Java

3 Upvotes

Persism is a light weight, auto discovery, autoconfiguration, and convention over configuration ORM (Object Relational Mapping) library for Java 17 or later.

By the numbers

  • 100k jar

  • 400+ unit tests

  • 90% code coverage

  • 11 supported dbs

  • 0 dependencies

Release Notes

General Documentation

Javadoc

Code coverage

Thanks for the support!


r/hibernate • • Jan 24 '22

Hibernate slowness 1,300% slower than JDBC

3 Upvotes

I have a very simple program that persists a collection of a given bean.

Using hibernate it takes 117,346 ms to insert and commit 10,000 records.

Using native JDBC this takes 8,559 ms to insert and commit the same 10,000 records.

That is 1,300% slower.

Is there some way to instrument hibernate or tune it? This table is very simple, has no foreign keys or referential constraints. It's not even reflection, because I use the exact same beans in hibernate as I store using native JDBC and converting the beans to maps using a caching reflection class I wrote.


r/hibernate • • Oct 20 '21

How to mess up statement batching in Hibernate

Thumbnail arnoldgalovics.com
3 Upvotes

r/hibernate • • Dec 02 '20

Hibernate: Does it eventually use SQL somewhere that I can see?

3 Upvotes

I'm debugging a massive application that uses Hibernate, which I am not familiar with.

I'm trying to find out why the application ( many confusing layers above Hibernate ) is sending out error messages about there being no data, when I can see the data in the database ( Postgres ).

Does Hibernate eventually somewhere deep down make SQL queries that I can see? Some other commands I can see such that I can learn what it is asking for so I can tell why it isn't finding it?


r/hibernate • • Jun 28 '19

With two tables, one-to-many, how can I make deleting one of the "many", also delete the "one", and also the others "many" associated to that "one"?

3 Upvotes

Does that even make sense? I have two tables, Person and Document. I have a one to many relationship, one person can have one document, but one document can have many persons. Is it possible to make it like if I delete a Person, the document also gets deleted along with all the other Persons related to that Document? I am using Spring Boot.


r/hibernate • • Jun 20 '13

How to create One to Many and Many to One mapping between two database tables using hibernate

Thumbnail
mrbool.com
3 Upvotes

r/hibernate • • Jun 11 '13

How to create Database Table using Hibernate

Thumbnail
mrbool.com
3 Upvotes

r/hibernate • • Jun 17 '23

Hibernate exception in Standalone JavaFX app and Derby.

2 Upvotes

Hi, I am building a Desktop app using JavaFX with an embedded DB(Derby) using Hibernate as ORM. It's a modular project. When I run the App in IDEA everything works fine and all CRUD Operations can be done though when I try to deploy the App using jlink and jpackage and run it as a standalone app, Hibernate fail with the error: java.lang.IllegalAccessError: superclass access check failed: class org.hibernate.HibernateException.


r/hibernate • • Jun 07 '23

DB Table to ORM using Hibernate with Mappings ( OnetoOne, ManytoMany,...... ) using Eclipse ID

2 Upvotes

Hi

If somebody has Link to Reverse Engg for the following

Existing DB with PK/FK to ORM code ( Java ) with mappings ( OnetoOne, OnttoMany ,ManytoMany, ManytoOne) using Eclipse / HibernateTools.

Please Share


r/hibernate • • Apr 03 '23

What the standard industry practice to get the time taken by a hibernate sql query

2 Upvotes

What the standard industry practice to get the time taken by a hibernate sql query


r/hibernate • • Mar 16 '23

Hibernate ORM 6.2 - CTE support - In Relation To

Thumbnail
in.relation.to
2 Upvotes

r/hibernate • • Feb 18 '23

JPA OneToMany mappings on Existing DB without additional key column changes

2 Upvotes

Howdy

Does anybody share 'OneToMany' mappings on Existing Tables ( which already has Primary/Foreign Key mapped at DB Level)

  1. Implementation should not make or change any of the key mappings on the Table.

  2. The Mappings are used to just fetch data via Entity beans from the 2 Tables using the Join Column


r/hibernate • • Jul 06 '22

Hibernate default constructors and DDD

2 Upvotes

DDD states that no aggregates should be in an invalid state during their lifetime. On the other hand, Hibernate requires a default constructor with no arguments. My aggregates should have some data in order to be in a valid state and having an instance with no data makes no sense in the domain. What am I missing? Thank you.


r/hibernate • • Nov 02 '21

Hibernate Interview Questions | Courseya

Thumbnail
courseya.com
2 Upvotes

r/hibernate • • Mar 22 '21

project has higher compiler option than running Eclipse

2 Upvotes

Hi, I am trying to use Hibernate in my java file however when I create a hibernate cfg xml file, I get the error saying " 'project' has higher compiler option than running Eclispe. Hibernate plugins unable to load its classes. Please decrease the compiler option or run the Eclipse with higher JDK level". Can anyone help me out with this? Thanks!


r/hibernate • • Jan 06 '21

Hibernate hogging memory

2 Upvotes

I am using heap analysis tool that showing Hibernate is hogging quite a bit of memory

Here's what it's showing: https://i.imgur.com/qmFQAmO.png

It's basically saying Hibernate has all these byte[] arrays in memory, coming from

org.hibernate.engine.query.spi.NamedParameterDescriptor.sourceLocations

I am not sure how to even approach this if it's even possible at all other than "stop using Hibernate"


r/hibernate • • Sep 03 '20

ERROR: column 'id' not found while using nativequery in hibernate 5.4.14

2 Upvotes

I'm getting:

ERROR: column 'id' not found while using session.createNativeQuery() 
in hibernate 5.4.14

What I have tried:

try (Session session = sessionFactory.openSession()) {     
var clients = session.createNativeQuery("select c.fullname, c.city from client c where c.id=:id")
        .addEntity("c", Client.class)
        .setParameter("id", id);

and there's filed "id" in entity and in a database too but getting:

Caused by: java.sql.SQLException: Column 'id' not found.

Here's entity class:

public class Client  implements java.io.Serializable {
    private Integer id;
    private Product product;      
    private String fullname;      
    private String business;     
    private String address; 

Here's Client.hbm.xml :

<class name="javafxapplication.pojo.Client" table="client" catalog="clientie" optimistic-lock="version">     
<id name="id" type="java.lang.Integer">         
<column name="id" />         
<generator class="identity" /></id> 

I'm using MySQL 8.0.21 Hibernate 5.4.14 JDK 11.0.8+10I won't use JPA Criteria cause I'm checking performance using NativeQuery.