Which annotation should I use for this to work?
I am trying:
Code:
    @ManyToOne(fetch=FetchType.EAGER)
    @JoinColumn(name = "IdNivel", nullable = false)
    @LazyToOne(value=LazyToOneOption.NO_PROXY)
    public NivelBolsaDTO getNivel() {
   return this.nivel;
    }
But it does not work. Once I close my session, and try to access this property I get an LazyInitializationException.
The object that has the nivel property has a constructor thas accepts the nivel as a parameter. I am creating two new objects with a NivelBolsaDTO loaded from the database but already disconnected from the session and I am trying to add both objects to a collection. The method add fails when on my overrided equals I try to get the value of the nivel property in order to compare it to the other object. Shouldn't this object be created as a regular object, and not a proxy? When I debug I can clearly see that when I create the object, the nivel property is a proxy.
Any explanations?
Thanks