• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

isNotNull & isNotEmpty Hibernate

 
Greenhorn
Posts: 15
Eclipse IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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...
 
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"Tabajara"

Please check your private message for a message from JavaRanch.
 
Jaikiran Pai
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

criteria.add(Restrictions.isNotEmpty("description"));



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:

 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
May I suggest you also check for the possibility of a null value ?

So, instead of having:

criteria.add(Restrictions.ne("description",""));

you could have:

criteria.add(Restrictions.and(Restrictions.ne("description",""), Restrictions.isNotNull("description")));
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic