Error accessing field by reflection for persistent property

I got this error in my sleep mode

Error accessing field [private java.lang.Integer br.com.moldargesso.moldar.entities.Cidade.id] by reflection for persistent property [br.com.moldargesso.moldar.entities.Cidade#id] : 1

      

Obra class

@Entity
@Table (name = "obras")
public class Obra {


    @Id
    @GeneratedValue (strategy = GenerationType.IDENTITY)
    @Column (name = "id")
    private Integer id;

    @OneToOne 
    @JoinColumn (name = "fk_cliente")
    private Cliente cliente;

    @OneToOne
    @JoinColumn (name = "fk_cidade")
    private Cidade cidade;

      

CIDADE class

@Entity
@Table (name = "cidade")
public class Cidade {

    @Id
    @GeneratedValue (strategy = GenerationType.IDENTITY)
    @Column
    private Integer id;

    @Column
    private String nome;

      

DAO

open list of lists (integer cidade) {

    Session session = HibernateUtil.getSessionFactory().openSession();
    Criteria criteria = session.createCriteria(Obra.class);

    if(cidade != null){

        criteria.add(Restrictions.and(
            Restrictions.eq("cidade", cidade)));
    }

    criteria.addOrder(Order.asc("id"));
    List<Obra> obraList = criteria.list();
    session.close();
    return obraList;
}

      

I do not know how to fix this, I am starting and I would like to fix it. Can anyone help me? Thank.

+3
java hibernate


source to share


No one has answered this question yet

Check out similar questions:

1975
What is reflection and why is it useful?
1338
Why does Java have transient fields?
877
Sorting ArrayList of custom objects by property
3
Hibernate: Why does the FetchType.LAZY-annotated collection property eagerly load?
2
Hibernate error persists in entity in @PostPersist method
2
Hibernate cannot delete parent / child merged object
1
MappingJackson2HttpMessageConverter Cannot find (Map) Key deserializer for type
0
want to add two different tables (classes) to one hibernation criterion
0
why does MyEclipse show join_table not found compile error
0
Criteria: ClassCastException Integer up to Long



All Articles
Loading...
X
Show
Funny
Dev
Pics