File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Object Relational Mapping and the fly likes Issue while trying to map extended class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Issue while trying to map extended class" Watch "Issue while trying to map extended class" New topic
Author

Issue while trying to map extended class

Mariano Austral
Greenhorn

Joined: Jul 27, 2007
Posts: 7
Hi all,
I have an issue with inheritance mapping, hope you can help.

Having the following structure:


@Entity
@Table (name= "Persons")
@Inheritance (strategy=InheritanceType.JOINED)
@SequenceGenerator(
name="SEQ_PERSON",
sequenceName="SEQ_PERSON")
public class Person implements Serializable {

@Id(name = "personId")
@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="SEQ_PERSON")
private Long id;
@Column(name = "name")
private String name;
//etc
}

@Entity
//DONT KNOW WHAT TO DO HERE
public class PersonWithDogs implements Serializable {

@OneToMany(mappedBy="owner",cascade=CascadeType.ALL)
private List<Child> dogs;

//getters and setters
}


(This is just an example, the system does not have persons and dogs.)

I have the standard joined inheritance structure, but recently I had to add a specialization of Person that only contains a bidirectional oneToMany relationship. The mapped is being done by the "Dog" object so besides the dogs table I need to create no new tables. In addition, Person has other specializations with their own tables.

There is no "PERSON_WITH_DOGS" table since it's not necessary. How do I annotate this?

Thanks!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Issue while trying to map extended class