Hi there,
I have an odd question. It is not a real problem, because I have a working work-around. But it is something that made me investigate a lot without any result.
Here is my problem:
I have a many-to-one relationship the is lazyly fetched.
Code:
    @ManyToOne(fetch = FetchType.LAZY, targetEntity = AbstractLibraryQuestion.class,
          cascade = { CascadeType.PERSIST, CascadeType.MERGE,
                              CascadeType.REFRESH })
    @JoinColumn(name = "LB_QSTN_ID")
    public T getLibraryQuestion() {
        return libraryQuestion;
    }
When I call this method getLibrbaryQuestion() I sometime get an object that has the concrete class AbstractLibraryQuestion and sometimes one that comes from the cache, where the class name is AbstractLibraryQuestion$$EnhancerByCGLIB$$9a9e8ce9
Here is my code how to deal with it:
Code:
        AbstractLibraryQuestion tmq;
        Object proxy = this.getLibraryQuestion();
        System.out.println("proxy.getClass().getName() = " + proxy.getClass().getName());
        if (proxy instanceof AbstractLibraryQuestion) {
            tmq = (AbstractLibraryQuestion) proxy;
        } else {
            tmq = AbstractLibraryQuestion.class.cast(((HibernateProxy) proxy).
                    getHibernateLazyInitializer().getImplementation());
        } 
This works just fine, but I still would like to know why my object sometimes is cached and sometimes not. 
I'd be happy about any information.
Thanks,
Johannes