SupportWriter space ↗
REFERENCE LIBRARY

References from other publishers

Republished articles with source attribution. This collection is separate from Diary Coding’s original guides and does not display ads.

Read original guides → · Editorial policy

FOR YOUR CURIOSITY

Latest notes.

HIBERNATE / NOTES</>↗
Hibernate26 Oct 2008

How do I use min, max, avg and sum Projections?

The code below demonstration the use of Projections.min(), Projections.max(), Projections.avg() and Projections.sum(). package org.kodejava.hibernate; import org.hibernate.SessionFactory; import org.hibernate.Session; import org.hibernate.HibernateException; import org.hibernate.Criteria; import org.hibernate.cfg.Configuration; import org.hibernate.criterion.Projections; import org.kodejava.hibernate.model.Track; public class MinMaxAvgSumProjectionsDemo { public static Sessio...

Wayan · 2 min read
HIBERNATE / NOTES</>↗
Hibernate25 Oct 2008

How do I select a single record using Hibernate Criteria?

The Criteria.uniqueResult() method make it easier to query a single instance of a persistence object. When no persistence found this method will return a null value. package org.kodejava.hibernate; import org.hibernate.Criteria; import org.hibernate.HibernateException; import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.cfg.Configuration; import org.hibernate.criterion.Restrictions; import org.kodejava.hibernate.model.Genre; public class Un...

Wayan · 2 min read
HIBERNATE / NOTES</>↗
Hibernate21 Oct 2008

How do I set the fetch mode for Criteria association?

o set the fetching mode for association we can call the Criteria‘s setFetchMode() method. We can use the FetchMode.SELECT or FetchMode.JOIN. package org.kodejava.hibernate; import org.hibernate.*; import org.hibernate.cfg.Configuration; import org.hibernate.criterion.Restrictions; import org.kodejava.hibernate.model.Record; import java.util.List; public class FetchModeDemo { public static Session getSession() throws HibernateException { String cfg = "hibernate.cfg.xml"; Sessi...

Wayan · 2 min read
HIBERNATE / NOTES</>↗
Hibernate20 Oct 2008

How do I count the total records using Projections?

The example below show how to get total row count using the Projections.rowCount(). The result of this query will be a single object of Integer that contains the result of executing an SQL select count (*) command. package org.kodejava.hibernate; import org.hibernate.SessionFactory; import org.hibernate.Session; import org.hibernate.HibernateException; import org.hibernate.Criteria; import org.hibernate.cfg.Configuration; import org.hibernate.criterion.Projections; import org...

Wayan · 2 min read
HIBERNATE / NOTES</>↗
Hibernate17 Oct 2008

How do I order the Criteria query result set?

In this demo you’ll see how to order the result set of out Criteria query. It can be done by adding the org.hibernate.criterion.Order into the Criteria object, and we can either order the result in ascending or descending order. package org.kodejava.hibernate; import org.hibernate.SessionFactory; import org.hibernate.Session; import org.hibernate.HibernateException; import org.hibernate.Criteria; import org.hibernate.cfg.Configuration; import org.hibernate.criterion.Order; im...

Wayan · 2 min read
HIBERNATE / NOTES</>↗
Hibernate15 Oct 2008

How do I add Restrictions to the Criteria object?

In this example you’ll learn how to add restrictions to the Criteria object. Using restriction we can narrow the result of our query. In the code below we add some restrictions such as Restrictions.eq(), Restrictions.like() and Restrictions.isNotNull(). In Hibernate framework you’ll find a lot of class the use a method chaining. As in the example […]

Wayan · 3 min read
✳

Knowledge grows when shared.

Stay curious. There is always something new to learn.

Explore notes ↗
Putu Adi Guna Permana
ABOUT THE AUTHOR

Dr (C). Ir. Putu Adi Guna Permana, S.Kom., M.Kom., IPM., ASEAN Eng.

Writer and founder of Diary Coding — sharing notes, tutorials, and experiences about programming for anyone who wants to keep learning.