Cannot Mix Named and Positional Parameters in Hibernate

Hibernate 4.3 to 5.2 throw QueryException: Cannot mix named and positional parameters when a stored procedure call registers parameters by name and by position. See the message in each version, what Hibernate 7.4 does with mixed HQL and native queries, and the fix.

Pure Native Scalar Queries Are Not Yet Supported: Fix

Hibernate 3.6 to 4.1 stop at startup with NotYetImplementedException when a named native query has no resultClass or resultSetMapping. See the real error, the @ColumnResult workaround and how Hibernate 7 returns scalar values.

JPA Tutorials

The Java Persistence API (JPA) is a Java application programming interface specification that describes the management of relational data in applications using Java Platform, Standard Edition and Java Platform, Enterprise Edition. This page lists down all tutorials available on this blog related to JPA. JPA Basics CRUD Operations Integration Related Happy Learning !!

Hibernate Criteria Query Guide: JPA CriteriaBuilder Examples

A Hibernate criteria query builds SQL from Java objects with CriteriaBuilder, CriteriaQuery and Root. Learn filters, joins, fetch joins, group by, subqueries, pagination, dynamic filters, bulk updates and the static metamodel in Hibernate 7, with the generated SQL for each query.

HQL Tutorial: Hibernate Query Language With Examples

Hibernate Query Language (HQL) queries entities and attributes instead of tables and columns. Learn HQL select, joins, join fetch, aggregates, subqueries, update, delete and insert in Hibernate 7, with the SQL Hibernate generates for each query.

Hibernate save vs saveOrUpdate vs update: Hibernate 7 Guide

Hibernate save(), update() and saveOrUpdate() were deprecated in Hibernate 6 and removed in Hibernate 7. We run the old methods on Hibernate 6.6, then show how persist() and merge() replace them for new, detached and managed entities.

Hibernate c3p0 Connection Pool Setup with Spring Boot 4

Configure c3p0 as Hibernate 7’s connection pool with hibernate.c3p0 settings, check it in the logs and with pool statistics, size it, close and test idle connections, find leaks, and use c3p0 as the DataSource in Spring Boot 4.

Hibernate In-memory Database for JUnit Tests with H2

Unit test Hibernate repositories against an in-memory H2 database with JUnit 6: one EntityManagerFactory per test class, data from import.sql, a fresh copy of the data before every test with truncate(), and the H2 settings and pitfalls that break tests.

Hibernate SessionFactory: 5 Ways to Build It in Hibernate 7

Build a Hibernate SessionFactory in Hibernate 7.4 with HibernatePersistenceConfiguration, the native StandardServiceRegistryBuilder and MetadataSources API, the Configuration class, hibernate.cfg.xml, or unwrap() from an EntityManagerFactory. Then share one factory across threads and close it at shutdown.

Oracle Java Interview Experience: Questions and Answers

Reader Sreenath Ravva shared these questions from an Oracle Enterprise Manager interview. This is a historical account, not an official Oracle question bank or a prediction of a current interview. The answers below make the original questions useful for revising Java, concurrency, JDBC and project discussions. I have tried to put links to web pages … Read more

Spring AbstractRoutingDataSource Example

AbstractRoutingDataSource is a very useful feature if we have a design which permits multiple databases based on certain criteria which may change for each user request. An example can be when we can use a particular database when the user belongs to a certain locale and switch to another locale if the user belongs to … Read more

Bean Property configurationClass Is Not Writable [Solved]

Spring throws “Bean property ‘configurationClass’ is not writable” when XML written for Hibernate 3 sets configurationClass on a newer LocalSessionFactoryBean. See the real error on Spring 7, the XML fix, and the Spring Boot 4 setup that needs no SessionFactory bean.

NoClassDefFoundError SessionFactoryImplementor in Hibernate

NoClassDefFoundError: org/hibernate/engine/SessionFactoryImplementor means a class built for Hibernate 3, usually Spring’s orm.hibernate3 transaction manager, runs with Hibernate 4 or newer. Find the jar, switch to the matching Spring package or align the Hibernate modules, and unwrap the SPI interface on Hibernate 7.

Hibernate BLOB and CLOB Mapping With @Lob (Hibernate 7)

Map BLOB and CLOB columns in Hibernate 7 with @Lob on byte[], String, Blob and Clob fields. See the generated column types on H2, MySQL and PostgreSQL, how to stream large files with Blob, and why @Basic(fetch = LAZY) needs bytecode enhancement.

Spring Security Siteminder Pre-authentication Example

So far we have learned about securing spring application using login form based security, custom user details security and many more such security related concepts. In this post, I am giving an example of scenario where use is already authenticated via any third party application or tool e.g. site minder which is very common interface … Read more

Hibernate @NaturalId: Natural Ids, Lookups and Caching

Map a natural id such as a license plate with Hibernate’s @NaturalId, load entities with em.find(…, KeyType.NATURAL), handle mutable and composite natural ids, and cache lookups with @NaturalIdCache, with the SQL and statement counts from Hibernate 7.4.

No row with the given identifier exists: Hibernate 7 Fix

Hibernate throws “No row with the given identifier exists” when a proxy or an eager load asks for an id that has no row. See the real Hibernate 7.4 exceptions for getReference(), lazy and eager associations and concurrent deletes, and fix them with find(), orphan cleanup, a foreign key constraint or @NotFound.

Java Best Practices Guide

A good programmer is one who write programs (not just code). It means writing the code units which are independent enough to be re-used in multiple ways, and still they remain robust. So let’s start identifying and learning some java best practices which can transform any code into the programs. 1. Java Design Best Practices … Read more

Errors in Named Queries: Fix the Hibernate Startup Error

Hibernate stops at startup with “Errors in named queries” when a JPQL named query uses a table name, a column name, SQL syntax or a broken parameter. See how to read NamedQueryValidationException in Hibernate 7 and fix each cause.

Hibernate Second Level Cache: How It Works (With Ehcache)

The Hibernate second level cache shares entity data across all sessions of an EntityManagerFactory. Learn the lookup order, what the cache stores, the concurrency strategies, collection and query caching, statistics and eviction with Hibernate 7.4 and Ehcache 3.

Hibernate First Level Cache: Persistence Context Explained

The Hibernate first level cache is the persistence context of one EntityManager. See with counted SQL on Hibernate 7.4 when find() and queries hit the database, how detach(), evict(), clear() and refresh() work, and how to keep long transactions small.

Hibernate Insert: persist(), merge() and HQL Insert Examples

To insert an object with Hibernate, we pass a new entity to persist() inside a transaction. Learn when the INSERT runs for IDENTITY, SEQUENCE and assigned ids, how merge() and HQL insert statements work, and what replaced Session.save() in Hibernate 7.

Spring View Layer Security using JSP Taglibs

So far in previous tutorials, we have learned about securing your application behind login form, custom user detail service and even method level security also. All these security implementations were on controller or model layer of MVC. Its time to add security in view layer. It is mostly needed when we want to hide certain … Read more

About Us

HowToDoInJava provides tutorials and how-to guides on Java and related technologies.

It also shares the best practices, algorithms & solutions and frequently asked interview questions.