-->
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.  [ 2 posts ] 
Author Message
 Post subject: Help with mapping owner interface
PostPosted: Mon Jul 16, 2007 3:47 am 
Newbie

Joined: Fri Jun 08, 2007 4:20 am
Posts: 13
Hello,

Similar to http://forum.hibernate.org/viewtopic.ph ... 52#2359052 (a little simpler), I am trying to find a way to map the following classes.

In a nutshell, a car can be owned by a person or an enterprise, and needs to know its owner.

Can anyone help? Thanks in advance

Code:
   @MappedSuperclass
   class AbstractModel {
      @EmbeddedId
      private UUID id = UUID.randomUUID();
   }

   interface CarOwner {
   }

   @Entity
   class Person extends AbstractModel implements CarOwner {
      @OneToMany
      List<Car> cars = new ArrayList<Car>();
   }

   @Entity
   class Enterprise extends AbstractModel implements CarOwner {
      @OneToMany
      List<Car> cars = new ArrayList<Car>();
   }

   @Entity
   class Car {
      @ManyToOne
      private CarOwner owner;
   }
[/code]


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 16, 2007 11:21 am 
Newbie

Joined: Fri Jun 08, 2007 4:20 am
Posts: 13
Anyone? Thanks!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.