openjpa-users mailing list archives

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

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:

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

@Entity
@Table(name = "VERTRIEBSPARTNER")
@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.

Thus:

@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?

Thanks,

Heiko

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.  
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message