Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@Sylinsic
Copy link
Contributor

@Sylinsic Sylinsic commented Jul 20, 2025

The issue

OracleDictionary utilises the getUnqualifiedName method for retrieving tables, but not for indexes or foreign keys.
As a result, openjpa is unable to locate indexes and foreign keys that were created on a previous initialisation, causing openjpa to attempt to create them again. Oracle throws an error when you attempt to do this, which causes exceptions to be thrown in openjpa.

Remediation

Adding getUnqualifiedName to the get index and foreign keys method remediates this issue, as openjpa can now retrieve the previously created indexes and foreign keys from the database.

Demonstration description:

This can be demonstrated by starting up an apache syncope installation (which utilises openjpa) with an oracle database.
The first start will fully initialise the database using OpenJPA as expected.
Upon restart of the syncope instance, OpenJPA attempts (and fails) to 'add' the foreign keys and indexes, as it does not recognise that they are already present.

Demonstration docker-compose.yml:

networks:
  openjpa:

services:
    db: 
      container_name: db
      image: gvenzl/oracle-free:23-slim
      restart: always
      environment:
        ORACLE_PASSWORD: syncope
        APP_USER: syncope
        APP_USER_PASSWORD: syncope
      networks:
        - openjpa
 
    syncope: 
      container_name: syncope
      depends_on:
        - db
      image: apache/syncope:4.0.0
      ports:
        - "18080:8080"
      restart: always
      environment:
        SPRING_PROFILES_ACTIVE: docker,oracle
        DB_URL: jdbc:oracle:thin:@//db:1521/FREEPDB1
        DB_SCHEMA: syncope
        DB_USER: syncope
        DB_PASSWORD: syncope
        DB_POOL_MAX: 20
        DB_POOL_MIN: 5
        OPENJPA_REMOTE_COMMIT: sjvm
        KEYMASTER_ADDRESS: http://syncope:8080/syncope/rest/keymaster
        KEYMASTER_USERNAME: anonymous
        KEYMASTER_PASSWORD: password
        SERVICE_DISCOVERY_ADDRESS: http://syncope:8080/syncope/rest/
        ANONYMOUS_USER: anonymous
        ANONYMOUS_KEY: password
      networks:
        - openjpa

Commands for demonstration

  1. docker compose up -d
  2. docker logs -f syncope
    • Wait for 'Started SyncopeCoreApplication in XX.XXX seconds' to appear in syncope logs. At this point, the database will have been fully initialised by OpenJPA
  3. docker stop syncope
  4. docker start syncope
  5. docker logs -f syncope
    • Observe logs of syncope, which will indicate the failure to create foreign keys (and subsequently a container restart due to syncope failing to fully start

N.b. JIRA issue will be opened once my apache JIRA account is created.

@struberg
Copy link
Member

Thank you for that fix! I've applied the PR and pushed it to master.

@struberg struberg closed this Jul 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants