Ver Mensaje Individual
  #3 (permalink)  
Antiguo 12/11/2014, 06:20
Avatar de jocryo
jocryo
 
Fecha de Ingreso: agosto-2014
Mensajes: 38
Antigüedad: 9 años, 8 meses
Puntos: 0
Respuesta: jpa IllegalArgumentException

el codigo de la clase Usuario es:
Código Java:
Ver original
  1. /*
  2.  * To change this license header, choose License Headers in Project Properties.
  3.  * To change this template file, choose Tools | Templates
  4.  * and open the template in the editor.
  5.  */
  6.  
  7. package co.com.glokal.almaviva.modelo.entity;
  8.  
  9. import java.io.Serializable;
  10. import javax.persistence.Basic;
  11. import javax.persistence.Column;
  12. import javax.persistence.Entity;
  13. import javax.persistence.GeneratedValue;
  14. import javax.persistence.GenerationType;
  15. import javax.persistence.Id;
  16. import javax.persistence.NamedQueries;
  17. import javax.persistence.NamedQuery;
  18. import javax.persistence.Table;
  19. import javax.persistence.UniqueConstraint;
  20. import javax.validation.constraints.NotNull;
  21. import javax.validation.constraints.Size;
  22. import javax.xml.bind.annotation.XmlRootElement;
  23.  
  24. /**
  25.  *
  26.  * @author jose.ceballos
  27.  */
  28. @Table(name = "usuario", uniqueConstraints = {
  29.     @UniqueConstraint(columnNames = {"usuario"})})
  30. @XmlRootElement
  31. @NamedQueries({
  32.     @NamedQuery(name = "Usuario.findAll", query = "SELECT u FROM Usuario u"),
  33.     @NamedQuery(name = "Usuario.findByUsuario", query = "SELECT u FROM Usuario u WHERE u.usuario = :usuario"),
  34.     @NamedQuery(name = "Usuario.findByPassword", query = "SELECT u FROM Usuario u WHERE u.password = :password"),
  35.     @NamedQuery(name = "Usuario.findByNombre", query = "SELECT u FROM Usuario u WHERE u.nombre = :nombre"),
  36.     @NamedQuery(name = "Usuario.findById", query = "SELECT u FROM Usuario u WHERE u.id = :id")})
  37. public class Usuario implements Serializable {
  38.     private static final long serialVersionUID = 1L;
  39.     @Basic(optional = false)
  40.     @NotNull
  41.     @Size(min = 1, max = 50)
  42.     @Column(name = "usuario", nullable = false, length = 50)
  43.     private String usuario;
  44.     @Basic(optional = false)
  45.     @NotNull
  46.     @Size(min = 1, max = 50)
  47.     @Column(name = "password", nullable = false, length = 50)
  48.     private String password;
  49.     @Basic(optional = false)
  50.     @NotNull
  51.     @Size(min = 1, max = 50)
  52.     @Column(name = "nombre", nullable = false, length = 50)
  53.     private String nombre;
  54.     @Id
  55.     @GeneratedValue(strategy = GenerationType.IDENTITY)
  56.     @Basic(optional = false)
  57.     @Column(name = "id", nullable = false)
  58.     private Integer id;
  59.  
  60.     public Usuario() {
  61.     }
  62.  
  63.     public Usuario(Integer id) {
  64.         this.id = id;
  65.     }
  66.  
  67.     public Usuario(Integer id, String usuario, String password, String nombre) {
  68.         this.id = id;
  69.         this.usuario = usuario;
  70.         this.password = password;
  71.         this.nombre = nombre;
  72.     }
  73.  
  74.     public String getUsuario() {
  75.         return usuario;
  76.     }
  77.  
  78.     public void setUsuario(String usuario) {
  79.         this.usuario = usuario;
  80.     }
  81.  
  82.     public String getPassword() {
  83.         return password;
  84.     }
  85.  
  86.     public void setPassword(String password) {
  87.         this.password = password;
  88.     }
  89.  
  90.     public String getNombre() {
  91.         return nombre;
  92.     }
  93.  
  94.     public void setNombre(String nombre) {
  95.         this.nombre = nombre;
  96.     }
  97.  
  98.     public Integer getId() {
  99.         return id;
  100.     }
  101.  
  102.     public void setId(Integer id) {
  103.         this.id = id;
  104.     }
  105.  
  106.     @Override
  107.     public int hashCode() {
  108.         int hash = 0;
  109.         hash += (id != null ? id.hashCode() : 0);
  110.         return hash;
  111.     }
  112.  
  113.     @Override
  114.     public boolean equals(Object object) {
  115.         // TODO: Warning - this method won't work in the case the id fields are not set
  116.         if (!(object instanceof Usuario)) {
  117.             return false;
  118.         }
  119.         Usuario other = (Usuario) object;
  120.         if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
  121.             return false;
  122.         }
  123.         return true;
  124.     }
  125.  
  126.     @Override
  127.     public String toString() {
  128.         return "co.com.glokal.almaviva.controlador.entity.Usuario[ id=" + id + " ]";
  129.     }
  130.    
  131. }