openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject Two Entities in an inheritance strategy InheritanceStrategy.JOINED -> always uses most specific Entity
Date Mon, 25 May 2009 09:44:38 GMT

In our database model, we have a relationship between a table called 
'Partner' and a table called 'Vertriebspartner' that specializes the first 
by adding more information to the 'Partner'. However, there is not always 
an entry in the table 'Vertriebspartner' for every 'Partner'.

In my model I currently have the following inheritance relation defined 
for these two tables:

@Table(name = "PARTNER", schema = "PART")
public class Partner
    @Column(name = "PART_KEY")
    private BigDecimal partKey;

@Inheritance(strategy = InheritanceType.JOINED)
@AttributeOverride(name="version", column=@Column(name="VERSION")) 
public class Vertriebspartner extends Partner 

I now have the problem, that in case I use a 'Partner' in a OneToMany or 
ManyToOne-Relationship, openJPA always tries (even though i use Partner 
and NOT Vertriebspartner) to join both. This leads to missing entries, as 
the join often leads to no entry at all, but there is definilty a Partner.


@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "PART_KEY", table = "WBZ_V")
private Partner partner;

ends in a select that joins Partner and Vertriebspartner. I even tried to 
apply targetEntity = Partner.class to the ManyToOne, but that did not help 
at all.

What do I do wrong here? Is the joined inheritance strategy not ment to be 
used when there is not always an entry available in the more specialized 
table? Is this maybe a problem in openJPA?



If you are not the intended addressee, please inform us immediately that you have received
this e-mail in error, and delete it. We thank you for your cooperation.  
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message