learn java
The moose likes Object Relational Mapping and the fly likes isNotNull  & isNotEmpty  Hibernate Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of The Software Craftsman this week in the Agile forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "isNotNull  & isNotEmpty  Hibernate" Watch "isNotNull  & isNotEmpty  Hibernate" New topic

isNotNull & isNotEmpty Hibernate

Thalys de Aguiar Gomes

Joined: Mar 31, 2008
Posts: 15

People need to have this list only the objects that this description field is not null and void... that there's more code giving ...

org.hibernate.MappingException: Property path [ClienteTO.description] does not reference a collection

If I shot this isNotNull and isNotEmpty he has much work to some customers who have ..... field null and I do not want that

someone could help me...

SCJP 5 - 74%, SCWCD - 89%, SCBCD in progress
Jaikiran Pai

Joined: Jul 20, 2005
Posts: 10403


Please check your private message for a message from JavaRanch.

[My Blog] [JavaRanch Journal]
Jaikiran Pai

Joined: Jul 20, 2005
Posts: 10403


The isNotEmpty restriction is meant for collections. Here's a comment from the javadoc:

Constrain a collection valued property to be non-empty

If you want to check the "description", which i guess is a String, is not an empty string, then you could do this instead:

Stephane Eybert
Ranch Hand

Joined: Mar 15, 2010
Posts: 34
May I suggest you also check for the possibility of a null value ?

So, instead of having:


you could have:

criteria.add(Restrictions.and(Restrictions.ne("description",""), Restrictions.isNotNull("description")));
Have you tried LearnNowOnline? http://www.learnnowonline.com/
subject: isNotNull & isNotEmpty Hibernate