How to initialize Hibernate with Reflection

Asked

Viewed 94 times

1

Hello, I need to initialize a list using Hibernate.initialize(list) within a Generic DAO.

User Model

@Entity
public class Usuario {

    @Expose
    @ManyToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE})
    private List<AreaAtuacao> areasAtuacao = new FastList<>();

    @Expose
    @ManyToMany(cascade = {CascadeType.MERGE})
    private List<AreaInteresse> areasInteresse = new FastList<>();

    @Expose
    @OneToOne(cascade = {CascadeType.ALL})
    private RegistroResponsavel registroResponsavel;
}

Model Registroresponsavel

@Entity
public class RegistroResponsavel {

    @Expose
    @OneToOne
    private Usuario usuarioCriacao;

    @Expose
    @Temporal(TemporalType.TIMESTAMP)
    private Date dataCriacao;

    @Expose
    @OneToOne
    private Usuario usuarioAlteracao;

    @Expose
    @Temporal(TemporalType.TIMESTAMP)
    private Date dataAlteracao;

}

How to initialize the list that is inside Registroresponsável > Usuario > areasAtuacao & areasInteresse, using Reflection?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.