Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » InheritanceType.JOINED not doing the correct JOIN with composite primary key(There is a problem when you try to use Inheritance.JOINED when the superclass has a composite primary key)
InheritanceType.JOINED not doing the correct JOIN with composite primary key [message #1853011] Tue, 14 June 2022 16:04 Go to next message
Alfonso Luna is currently offline Alfonso LunaFriend
Messages: 14
Registered: March 2010
Junior Member
I dont know if this is a bug or there is something I am missing, but there is a problem when you try to use Inheritance.JOINED when the superclass has a composite primary key.

I have the following classes: (Superclass)

@Entity
@Table(name = "tipos_opciones_misiones")
@IdClass(TipoOpcionMisionId.class)
@Inheritance(strategy = InheritanceType.JOINED)
@DiscriminatorColumn(name = "clase", discriminatorType = DiscriminatorType.STRING)
@ReadOnly
public abstract class TipoOpcionMision{
    @Id
    @ManyToOne
    @JoinColumn(name="tipo_mision")
    private TipoMision tipoMision;

    @Id
    @Column(name = "numero")
    private int numero;
}



And a child class:
@Entity
@Table(name="tipos_misiones_opciones_comercio_compra")
@DiscriminatorValue("COMERCIO_COMPRA")
public class TipoOpcionMisionComercioCompra extends TipoOpcionMision{

    @Column(name="valor")
    double valor;
}


When I try to get a list on objects "TipoOpcionMision" the generated SQL ignores that there is a composite key [tipo_mision, numero] and it just uses "t1.numero = t0.numero". There should also be a "t1.tipo_mision= t0.tipo_mision".

SELECT **list of fields***,  FROM tipos_misiones_opciones t0, tipos_misiones_opciones_comercio_compra t1 WHERE ((t0.tipo_mision = 'MISION_1') AND ((t1.numero = t0.numero) AND (t0.clase = 'COMERCIO_COMPRA')))


There is no errors, but I get false results because I am getting the values of the first row in the cartesian product.

I have tried to add:

@PrimaryKeyJoinColumns({
        @PrimaryKeyJoinColumn(name = "tipo_mision", referencedColumnName = "tipo_mision"),
        @PrimaryKeyJoinColumn(name = "numero", referencedColumnName = "numero")
})  


But program fails when starting with the following error:

Exception Description: A @PrimaryKeyJoinColumns was found on the annotated element [class TipoOpcionMisionComercioCompra]. When the entity uses a single primary key, only a single (or zero) @PrimaryKeyJoinColumn should be specified.


It seems that for some reason Eclipselink is ignoring tthat the superclass has a composite primary key.

[Updated on: Tue, 14 June 2022 22:45]

Report message to a moderator

Re: InheritanceType.JOINED not doing the correct JOIN with composite primary key [message #1853023 is a reply to message #1853011] Wed, 15 June 2022 08:46 Go to previous message
Alfonso Luna is currently offline Alfonso LunaFriend
Messages: 14
Registered: March 2010
Junior Member
What do you think? does it look like a bug?
Previous Topic:JPA project classpath for JDBC driver dependencies
Next Topic:BUG - @PrimaryKeyJoinColumns causes [EclipseLink-7223] when existing a composite primary key
Goto Forum:
  


Current Time: Sat Jan 25 22:11:42 GMT 2025

Powered by FUDForum. Page generated in 0.02766 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top