-->
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.  [ 1 post ] 
Author Message
 Post subject: inheritance mapping
PostPosted: Tue Aug 30, 2011 8:21 am 
Newbie

Joined: Tue Aug 30, 2011 7:58 am
Posts: 1
Hi,we're getting some dificult to map this scenario:

Code:
@Entity
class ScrapBook{
   @Id@GeneratedValue(strategy=GenerationType.IDENTITY)
   int id;
   @OneToMany(mappedBy="scrapBook", fetch=FetchType.LAZY) 
   List<PageSet> pageSet;
}

@Entity
class PageSet{
   @Id@GeneratedValue(strategy=GenerationType.IDENTITY)
   int id;
   @ManyToOne( cascade={CascadeType.ALL})
   ScrapBook scrapBook;
   @OneToOne@JoinColumn(name="id", unique=false, nullable=true)
   LandscapePage landscapePage;
   @OneToOne@JoinColumn(name="id", unique=false, nullable=true)
   PortraitPage     portraitPage;
}

@MappedSuperclass
class Page{
   @Id@GeneratedValue(strategy=GenerationType.IDENTITY)
   id;
   @ManyToOne( cascade={CascadeType.ALL})
   PageSet pageSet;
   @OneToMany(mappedBy="page", fetch=FetchType.LAZY) 
   List<Photo> photos;
}

@Entity
class LandscapePage extends Page{}

@Entity
class PortraitPage extends Page{}

@Entity
class Photo{
   @Id@GeneratedValue(strategy=GenerationType.IDENTITY)
   int id;
   @ManyToOne( cascade={CascadeType.ALL})
   Page page;
}


How can we do a reverse mapping Photo->(LandscapePage/PortraitPage) ?
We would like to mantain all pages(landscape an portrait) on a single table.

Thanks in advance


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

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.