-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Using inheritance to model summary/details pattern
PostPosted: Tue Dec 20, 2005 2:45 am 
Newbie

Joined: Thu Dec 15, 2005 2:30 pm
Posts: 10
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?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 20, 2005 3:38 pm 
Regular
Regular

Joined: Tue Jan 06, 2004 3:32 pm
Posts: 80
Location: Munich, Germany
Yes, you haven't got defined a column for your id (instead, you are mapping a Date to your id column - is this really what you want?).

Also, look at the @Inheritance annotation, which might be required (I don't know exactly).


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 20, 2005 4:00 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
the lightweight pattern is currently not supported through annotations, but you can use projections select new Summary(i.name, i.price) from Item i

_________________
Emmanuel


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.