lazy « Entity « JPA Q&A





1. Is an entity marked as lazy="true" cached?    forum.hibernate.org

Can someone confirm my observation below? Does hibernate cache an entity marked as cacheable and lazy (default configuration for a class with hibernate 3.x) ? From my observation, if I mark an persistent class as lazy="false" in hbm.xml , the entity is stored and fetched from cache when invoked through apis like load() , iterate() , etc; otherwise it is not. ...

2. entity SINGLE_TABLE lazy=true ClassCastException    forum.hibernate.org

Hibernate 3.2 Parent class: @Entity @Table(name="message") @Inheritance(strategy=InheritanceType.SINGLE_TABLE) @DiscriminatorColumn( name="MESSAGE_CLASS", discriminatorType=DiscriminatorType.INTEGER ) public abstract class Message {... Subclass: @Entity @Inheritance(strategy=InheritanceType.SINGLE_TABLE) @DiscriminatorValue("1") public class StructuredLetter extends Message {... When I run the following code I get a java.lang.ClassCastException: com.gudrun.gdp3000.business.messagecenter.domain.Message$$EnhancerByCGLIB$$8c8c7d71 StructuredLetter letter = (StructuredLetter) messageDAO.get(id); This is logical because this Hibernate-cglib class is put in between because of lazy loading. But how can I ...