Ver Mensaje Individual
  #3 (permalink)  
Antiguo 23/02/2010, 10:14
chugui
 
Fecha de Ingreso: febrero-2010
Mensajes: 29
Antigüedad: 14 años, 8 meses
Puntos: 0
Respuesta: hibernate + icefaces + anotaciones

gracias por contestar amigo... aqui esta el codigo de donde se genera la excepcion!

public boolean validate(String user, String pass){
Session session = hibernateannotations1.HibernateUtil.getSessionFact ory().getCurrentSession();
session.beginTransaction();
Query query = session.getNamedQuery("User.findByUserName");
query.setParameter("userName", user);
List<User> list = query.list();

for(User u: list){
if(u.getUserPass().equals(pass))
return true;
}
return false;
}



y este otro pedazo es la clase User donde se supone que esta el query según entendi mediante el video!

@Entity
@Table(name = "USERS")
@NamedQueries({@NamedQuery(name = "User.findAll", query = "SELECT u FROM User u"), @NamedQuery(name = "User.findByUserId", query = "SELECT u FROM User u WHERE u.userId = :userId"), @NamedQuery(name = "User.findByUserName", query = "SELECT u FROM User u WHERE u.userName = :userName"), @NamedQuery(name = "User.findByUserPass", query = "SELECT u FROM User u WHERE u.userPass = :userPass")})

public class User implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@Basic(optional = false)
@Column(name = "USER_ID")
private Integer userId;
@Column(name = "USER_NAME")
private String userName;
@Column(name = "USER_PASS")
private String userPass;

public User() {
}

public User(Integer userId) {
this.userId = userId;
}

public Integer getUserId() {
return userId;
}

public void setUserId(Integer userId) {
this.userId = userId;
}

public String getUserName() {
return userName;
}

public void setUserName(String userName) {
this.userName = userName;
}

public String getUserPass() {
return userPass;
}

public void setUserPass(String userPass) {
this.userPass = userPass;
}

@Override
public int hashCode() {
int hash = 0;
hash += (userId != null ? userId.hashCode() : 0);
return hash;
}

@Override
public boolean equals(Object object) {
// TODO: Warning - this method won't work in the case the id fields are not set
if (!(object instanceof User)) {
return false;
}
User other = (User) object;
if ((this.userId == null && other.userId != null) || (this.userId != null && !this.userId.equals(other.userId))) {
return false;
}
return true;
}

@Override
public String toString() {
return "hibernateannotations1.User[userId=" + userId + "]";
}

}