Hi all, I`m trying to use the hibernate 3 with annotations and I`m stoped in a basic and a simple problem (to me this is a basic without annotations), but now I`m trying to use it.
Well, let`s before to stacktrace:
Quote:
2006-06-07 15:48:13,828 [http-8080-Processor25 ERROR ExceptionInterceptor]: IllegalArgumentException occurred calling getter of org.javafree.enviador.model.Estado.estadoId; nested exception is org.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of org.javafree.enviador.model.Estado.estadoId
org.springframework.orm.hibernate3.HibernateSystemException: IllegalArgumentException occurred calling getter of org.javafree.enviador.model.Estado.estadoId; nested exception is org.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of org.javafree.enviador.model.Estado.estadoId
Caused by:
org.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of org.javafree.enviador.model.Estado.estadoId
at org.hibernate.property.BasicPropertyAccessor$BasicGetter.get(BasicPropertyAccessor.java:171)
at org.hibernate.tuple.AbstractEntityTuplizer.getIdentifier(AbstractEntityTuplizer.java:176)
.....
Quote:
Caused by: java.lang.IllegalArgumentException: object is not an instance of declaring class
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.hibernate.property.BasicPropertyAccessor$BasicGetter.get(BasicPropertyAccessor.java:145)
... 103 more
Ok, now I`ll show to you my classes:
Code:
package org.javafree.enviador.model;
import java.io.Serializable;
import java.util.List;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.OrderBy;
@Entity
public class Estado extends Model implements Serializable {
private static final long serialVersionUID = 1L;
private Long estadoId;
private String name;
private String abrev;
private List<User> users;
private List<Vaga> vagas;
private List<Vaga> empresasEstado;
@Column(name="estado_id")
@Id @GeneratedValue(strategy=GenerationType.AUTO)
public Long getEstadoId() {
return estadoId;
}
public void setEstadoId(Long estadoId) {
this.estadoId = estadoId;
}
public String getAbrev() {
return abrev;
}
public void setAbrev(String abrev) {
this.abrev = abrev;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@OneToMany(mappedBy="estadoUser")
@OrderBy("id desc")
public List<User> getUsers() {
return users;
}
public void setUsers(List<User> users) {
this.users = users;
}
@OneToMany(mappedBy="vagaEstado")
@OrderBy("dataCriacao desc")
public List<Vaga> getVagas() {
return vagas;
}
public void setVagas(List<Vaga> vagas) {
this.vagas = vagas;
}
@OneToMany(mappedBy="empresaEstado")
@OrderBy("dataCriacao desc")
public List<Vaga> getEmpresasEstado() {
return empresasEstado;
}
public void setEmpresasEstado(List<Vaga> empresasEstado) {
this.empresasEstado = empresasEstado;
}
}
And:
Code:
@Entity
@NamedQuery(name="user.QuickSearch",
query="select u from User u where (u.area.areaId = :areaId and u.estadoUser = :estado) " +
" and (u.areaDesejada like '%'||:key||'%' or " +
" u.experiences like '%'||:key||'%' or u.expProfissional like '%'||:key||'%' or " +
" u.cursos like '%'||:key||'%' or u.infos like '%'||:key||'%')")
public class User extends Model implements Serializable {
private static final long serialVersionUID = -2525920429794300046L;
private Long id;
private String fullName;
private Date birthDate;
private String gender;
private String userName;
private String password;
private Estado estadoUser;
private String cidade;
private String email;
private String foneCelular;
private String foneResidencial;
private String foneComercial;
private String site;
private String areaDesejada;
private Area area;
private String anosExperiencia;
private int newsletter;
private String experiences;
private String expProfissional;
private String escolaridade;
private String cursos;
private String infos;
private Integer visualizacoes;
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
@Column(name="user_id")
@Id @GeneratedValue(strategy=GenerationType.AUTO)
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
@Column(name="user_name")
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
@Column(name="full_name")
public String getFullName() {
return fullName;
}
public void setFullName(String fullName) {
this.fullName = fullName;
}
@Column(name="experience_years")
public String getAnosExperiencia() {
return anosExperiencia;
}
public void setAnosExperiencia(String anosExperiencia) {
this.anosExperiencia = anosExperiencia;
}
@Column(name="wanted_area")
public String getAreaDesejada() {
return areaDesejada;
}
public void setAreaDesejada(String areaDesejada) {
this.areaDesejada = areaDesejada;
}
@Column(name="city")
public String getCidade() {
return cidade;
}
public void setCidade(String cidade) {
this.cidade = cidade;
}
@Column(name="courses")
public String getCursos() {
return cursos;
}
public void setCursos(String cursos) {
this.cursos = cursos;
}
@Column(name="graduation")
public String getEscolaridade() {
return escolaridade;
}
public void setEscolaridade(String escolaridade) {
this.escolaridade = escolaridade;
}
@Column(name="estado_id")
@ManyToOne( cascade = {CascadeType.PERSIST, CascadeType.MERGE} )
@JoinColumn(name="estado_id", insertable=false, updatable=false)
public Estado getEstadoUser() {
return estadoUser;
}
public void setEstadoUser(Estado estadoUser) {
this.estadoUser = estadoUser;
}
@Column(name="experiences")
public String getExperiences() {
return experiences;
}
public void setExperiences(String experiences) {
this.experiences = experiences;
}
@Column(name="prof_experience")
public String getExpProfissional() {
return expProfissional;
}
public void setExpProfissional(String expProfissional) {
this.expProfissional = expProfissional;
}
@Column(name="mobile_phone")
public String getFoneCelular() {
return foneCelular;
}
public void setFoneCelular(String foneCelular) {
this.foneCelular = foneCelular;
}
@Column(name="business_phone")
public String getFoneComercial() {
return foneComercial;
}
public void setFoneComercial(String foneComercial) {
this.foneComercial = foneComercial;
}
@Column(name="home_phone")
public String getFoneResidencial() {
return foneResidencial;
}
public void setFoneResidencial(String foneResidencial) {
this.foneResidencial = foneResidencial;
}
@Column(name="additional_info")
public String getInfos() {
return infos;
}
public void setInfos(String infos) {
this.infos = infos;
}
@Column(name="newsletter")
public int getNewsletter() {
return newsletter;
}
public void setNewsletter(int newsletter) {
this.newsletter = newsletter;
}
@Column(name="site")
public String getSite() {
return site;
}
public void setSite(String site) {
this.site = site;
}
@Column(name="birth_date")
public Date getBirthDate() {
return birthDate;
}
public void setBirthDate(Date birthDate) {
this.birthDate = birthDate;
}
@ManyToOne( cascade = {CascadeType.PERSIST, CascadeType.MERGE} )
@JoinColumn(name="area_id")
public Area getArea() {
return area;
}
public void setArea(Area area) {
this.area = area;
}
public String getGender() {
return gender;
}
public void setGender(String gender) {
this.gender = gender;
}
public Integer getVisualizacoes() {
return visualizacoes;
}
public void setVisualizacoes(Integer visualizacoes) {
this.visualizacoes = visualizacoes;
}
}
Take a look to relationship called "vagas", this works ok, but when I load the User entity, the exception was happen.
I`m bored with this exception, because I read all annotations documentation and my relationships are ok, I don`t know what I have to change to this damm it relationship works!
Hahaha..
Well, thanks a lot guys