Rafael Roque Rafael Roque - 6 months ago 13
Java Question

Mapping Java boolean to Oracle number

I have a property created like this in my model:

public class Client {
private Boolean active;


}

My RDBMS is Oracle,and the column is a number(1,0)

How can I use the Restrictions API to achieve the following functionality?

criteria.add(Restrictions.eq("active"),object.isActive());

Answer

Hibernate does the Boolean to Oracle NUMBER(1,0) automatically, so you can use a Boolean value in your Criteria queries and the generated SQL will use the database boolean format instead.

Comments