Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8153351
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T15:59:13+00:00 2026-06-06T15:59:13+00:00

I have Eclipselink persistence provider tuned on DB2 DB. Where is 3 tables which

  • 0

I have Eclipselink persistence provider tuned on DB2 DB. Where is 3 tables which simplified definition are listed below:

CREATE TABLE root
(
    id       CHAR(32) NOT NULL PRIMARY KEY,
    rec_type VARCHAR(20)
);

CREATE TABLE derived
(
    id CHAR(32) NOT NULL PRIMARY KEY,
    ...
);
ALTER TABLE derived ADD CONSTRAINT fk_derived_to_root FOREIGN KEY (id) REFERENCES root(id);

CREATE TABLE secondary
(
    derived_id NOT NULL PRIMARY KEY,
    ...
);
ALTER TABLE secondary ADD CONSTRAINT fk_secondary_to_derived FOREIGN KEY (derived_id) REFERENCES derived(id);

Java entity classes for these entities are listed below,
RootEntity:

@javax.persistence.Table(name = "ROOT")
@Entity
@DiscriminatorColumn(name = "REC_TYPE")
@Inheritance(strategy = InheritanceType.JOINED)
public class RootEntity {
    private String id;

    @javax.persistence.Column(name = "ID")
    @Id
    @GeneratedValue(generator = "system-uuid")
    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    private String principalType;
    @Column(name = "PRINCIPAL_TYPE")
    public String getPrincipalType() {
        return principalType;
    }

    public void setPrincipalType(String principalType) {
        this.principalType = principalType;
    }
   ...
}

DerivedEntity:

@javax.persistence.Table(name = "DERIVED")
@Entity
@DescriminatorValue("DERIVED")
public class DerivedEntity extends RootEntity {
    private SecondaryEntity secondaryEntity;

    @OneToOne(mappedBy = "derived_id")
    public SecondaryEntity getSecondaryEntity() {
        return secondaryEntity;
    }

    public void setSecondaryEntity(SecondaryEntity secondaryEntity) {
        this.secondaryEntity = secondaryEntity;
    }
 ...
}

I see no derived table insertion in the test logs:

--INSERT INTO ROOT (ID, REC_TYPE) VALUES (?, ?)
    bind => [241153d01c204ed79109ce658c066f4c, Derived]
--INSERT INTO SECONDARY (DERIVED_ID, ...) VALUES (?, ...)
    bind => [241153d01c204ed79109ce658c066f4c, ...]
Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.3.2.v20111125-r10461): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: com.ibm.db2.jcc.am.fo: DB2 SQL Error: SQLCODE=-530, SQLSTATE=23503, SQLERRMC=SCHEM.SECONDARY.FK_SECONDARY_TO_DERIVED, DRIVER=3.57.82

So question is: why Eclipselink don’t insert new record into DERIVED table prior to insertion to SECONDARY table?

P.S. Everything is working fine when no SECONDARY table (ROOT and DERIVED tables only) or no inheritance used (DERIVED tables generates id).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T15:59:15+00:00Added an answer on June 6, 2026 at 3:59 pm

    For inheritance JPA assumes the foreign key constraints in related table refer to the root table.

    You can change your constraint to refer to the root table, or,

    use a DescriptorCustomizer to set,

    descriptor.setHasMultipleTableConstraintDependecy(true);
    

    or,

    customizer the OneToOneMapping to have its foreign key refer to the secondary table (JPA annotation always make it refer to the root table).

    Please log a bug though, as JPA join columns should allow you to define a foreign key to the secondary table.

    The reason that EclipseLink does defer the insert into the secondary table is to allow inserts to be grouped by tables to allow batch writing and avoid database deadlocks.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We use EclipseLink for persistence, and have configured EclipseLink to automatically create the database
I am creating a webapp with EclipseLink for the persistence layer, and I have
I am using eclipselink for JPA . I have an entity, which has a
Weird stuff... I have happily used EclipseLink / JPA 2 as provider for my
Can't test a jpa/maven project. I have the error javax.persistence.PersistenceException: No Persistence provider for
I have a running web service (using EclipseLink as JPA provider) and would like
I'm working on switching my JPA persistence provider from EclipseLink 2.3 to Hibernate 3.6.5.Final.
I use JPA persistence for my data models with Eclipselink as the persistence provider.
I have a problem with JPA (EclipseLink). I am not able to delete a
I have entity model like this (using EclipseLink and JPA 2.0): @Entity class A

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.