I have a web page that first displays a list of items (showing only a "summary" of items' properties), where each item links to a "details" page. What I am trying to do is to only load the "summary" fileds on the first page, but go ahead and load all the remaining fileds for the item on the "details" page.
I am trying to achieve that by using object inheritance as follows:
Code:
@Entity(access=AccessType.FIELD)
@Table(name="documents")
public class DocumentSummary {
@Id private Long id;
@Column(name="id") private Date date;
@Column(name="name") private String name;
...
}
@Entity(access=AccessType.FIELD)
@Table(name="documents")
public class DocumentDetails extends DocumentSummary {
@Column(name="data") private byte[] data;
...
}
But I get the following error: "org.hibernate.AnnotationException: No identifier specified for entity: DocumentDetails"
After reading through the documentation I then tried changing @Entity to @EmbeddableSuperclass on DocumentSummary. But now whenever I try to load DocumentSummary objects, for some reason "data" column DOES get pulled in (according to SQL shown with hibernate.show_sql=true), even though it is not part of DocumentSummary but DocumentDetails instead.
Am I doing something wrong?