I understand this is a pretty novice question, but after searching for a while, and looking at two books, I still need people help.
I have an object that has a name, address, and telephone number.
User user = new User(); user.setName("Jenny"); user.setAddress("1313 MockingBird"); user.setNumber("8675309");//get it.. //blah session session.save(user);
Now if I want to add a condition so this user is not added if number 8675309 is present, how. Normally in SQL I can do some if's but I can find out if HQL or Criteria is the way. This has to be in code, I can't put 'Number' field as a primary key, because there are times when this would be allowed.
Basically, boolean saved = save(user) if ((from User where Address = "8675309") = null) if(save){ //goto save page }else{ //error display
I do apologize if this is easy and I just can't find the api for it. Thanks!
|