spring - nullpointerexception while using if condition -


im using hibernate criteria spring(both annotation) im having nullpointerexception service class :

    public list<voiture> rechercher_voiture(string type, string couleur,          string lieulocation) {     list<voiture> v = new arraylist<voiture>();     criteria crit;     session session = dao.getsessionfactory().getcurrentsession();       crit = session.createcriteria(voiture.class)             .add(restrictions.eq("type", type))             .add(restrictions.eq("lieulocation", lieulocation))             .add(restrictions.eq("statut", (long) 0));           if(couleur.isempty()==false) {             crit.add(restrictions.eq("couleur", couleur));         } v = crit.list();      return v; } 

the nullpointerexception caused if condition suggestion?

it happens if couleur = null. change if(couleur!=null && couleur.isempty()==false)


Comments

Popular posts from this blog

How to run C# code using mono without Xamarin in Android? -

c# - SharpSsh Command Execution -

python - Specify path of savefig with pylab or matplotlib -