Tag: Hibernate

Hibernate-Search Multiple-value Facet-Counts

Hibernate-Search Multiple-value Facet-Counts

Introduction The hibernate-search facet search API is pretty amazing but it lacks a little on the following: Facet-Count values are incorrect where a facet matches a fields that have multiple values. I.e. the facet-counts are correct where the facet has a 1-to-many relationship with result-set items but the facet-counts are […]

Hibernate – Populating an unmapped Entity field with COUNT(*) using @Formula

Hibernate – Populating an unmapped Entity field with COUNT(*) using @Formula

This post demonstrates how to populate an Entity Bean property that is not mapped to a DB table column. It uses the @Formula annotation to insert native SQL into the hibernate generated query. My

Hibernate @ManyToMany delete non-owner – prevent owner being deleted

Hibernate @ManyToMany delete non-owner – prevent owner being deleted

The solution to deleting a child in a @ManyToMany relationship and deleting the parents in the process.

Java Hibernate ManyToMany Tutorial – With Add and Delete examples

Java Hibernate ManyToMany Tutorial – With Add and Delete examples

The many-to-many mappings and usage thereof can be a little bit weird on first glance. This tutorial demonstrates: The mappings (Annotations not XML). Adding an entity to a group. Removing an entity from a group. Listing parents with children. Listing children with parents. (The Hibernate Logic is completely separate from […]

Custom Annotated Validation with Spring 3 Web MVC

Custom Annotated Validation with Spring 3 Web MVC

My previous tutorial detailed using Hibernate Validation within Spring 3 Web MVC.  This tutorial shows how to create custom validation annotations. E.g.

This example annotation only permits the word ‘John’. Optionally, it can be case-sensitive. 

Validation for Hibernate in Spring 3 Web MVC (with Netbeans)

Validation for Hibernate in Spring 3 Web MVC (with Netbeans)

This blog details how to apply Validation to Spring 3 Web MVC forms using Hibernate’s validation framework.

Integrating Hibernate with Spring 3 Web MVC

Integrating Hibernate with Spring 3 Web MVC

This tutorial on “Integrating Hibernate with Spring 3 Web MVC” incorporates: Hibernate Transaction Control @RequestMapping friendly URL’s. More on this specific Spring 3 Web MVC friendly URL topic here. (Alternative @RequestParam method here) A Generic DAO suitable for Hibernate operations with Spring 3 Web MVC. More here in this separate […]

A Generic DAO for Hibernate

A Generic DAO for Hibernate

This short blog shares one Generic DAO (Data Access Object) for Hibernate that may be useful in a Spring 3 project. The source code is available for download at the bottom of this page.

Determining the primary key value of an entity bean using reflection

Determining the primary key value of an entity bean using reflection

Given some Entity Object or generic type T, it may be useful to determine the value of the primary key without knowing the object type.

Determining the primary key property name using Hibernate

Determining the primary key property name using Hibernate

Simple method:

String idPropertyName = sessionFactory.getClassMetadata(User.class).getIdentifierPropertyName(); To get the actual value see this tutorial Elaboration