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

  • SEARCH
  • Home
  • 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 8074627
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T14:43:06+00:00 2026-06-05T14:43:06+00:00

Hi, I am using the EclipseLink API to create dynamic entities to represent a

  • 0

Hi,

I am using the EclipseLink API to create dynamic entities to represent a graph stored in database tables. The links are stored in their own table, which contains a link ID column, the start node ID and the end node ID columns, plus other user-defined columns. The nodes have their own table, where a node ID is stored plus other user-defined columns.

When doing the mapping from the links table to the nodes table I am doing this with the API:

OneToOneMapping startNodeMapping = dynamicLinkTypeBuilder.addOneToOneMapping("startNode", dynamicNodeTypeBuilder.getType(), "NODE_ID");     
OneToOneMapping endNodeMapping = dynamicLinkTypeBuilder.addOneToOneMapping("endNode", dynamicNodeTypeBuilder.getType(), "NODE_ID");

When running the previous code I receive the following message in the stack trace:

Local Exception Stack: Exception [EclipseLink-48] (Eclipse Persistence Services - 2.3.0.v20110604-r9504): org.eclipse.persistence.exceptions.DescriptorException
Exception Description: Multiple writable mappings exist for the field [TEST_NETWORK_LINK.NODE_ID].  Only one may be defined as writable, all others must be specified read-only.
Mapping: org.eclipse.persistence.mappings.OneToOneMapping[startNodeId]

This exception is thrown because I am mapping two fields (startNode and endNode) from the same entity to the same column/field in a different table/entity.

Do you know what could I do in order to solve this mapping problem? Would you suggest a different strategy? I cannot change the tables structure and I don’t want to make one of the mappings “read only”, but I am free to change the dynamic mappings.

Thank you!

  • 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-05T14:43:08+00:00Added an answer on June 5, 2026 at 2:43 pm

    The problem is as the error message states – you are using the “NODE_ID” field as a foreign key in both the startNode and endNode mappings. Essentially your object’s startNode will always == the endNode when read back from the database. I believe you will want to specify different fields for the two mappings if they are meant to reference different nodes, so that they use their own foreign key. eg:

    OneToOneMapping startNodeMapping = dynamicLinkTypeBuilder.addOneToOneMapping(“startNode”, dynamicNodeTypeBuilder.getType(), “START_NODE_ID”);
    OneToOneMapping endNodeMapping = dynamicLinkTypeBuilder.addOneToOneMapping(“endNode”, dynamicNodeTypeBuilder.getType(), “END_NODE_ID”);

    Both will automatically reference the primary key in the referenced table, which I assume is “NODE_ID”.

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

Sidebar

Related Questions

I'm using Eclipselink to map my tables to entities. I have one big database
I am using Eclipselink, Spring and an Oracle database. How should I configure security
I'm working in a java project using eclipse, eclipseLink, java persistence API (JPA) and
I'm using EclipseLink for a web project involving EJB 3 and Oracle stored procedures.
I am using eclipselink, and I have the following code to call a stored
This is similar to How to cascade persist using JPA/EclipseLink I have to entities
I'm using EclipseLink 2.3.1 to model self referencing table with JPA 2. I get
I'm using Eclipselink and I'm trying figure out the best way to create a
Using JPA 2 with EclipseLink implementation. I'm trying to build a dynamic query which
I am creating an application with eclipselink JPA, I am using HistoryPlicy to create

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.