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 6027341
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T04:34:43+00:00 2026-05-23T04:34:43+00:00

I would like to evaluate JPA on an existing project. The database model and

  • 0

I would like to evaluate JPA on an existing project. The database model and the java classes exists and are currently mapped via self generated code. The database model and the java classes do not fit ideally together – but the custom mapping works well. Nevertheless the usage of JPA in general seems worth a try.

As you see I am new to JPA and have to do the work with xml configuration. Currently I am working on a one-to-many unidirectional relationship using a join table (please do not discuss this szenario here).

A (one - relationship owner) <-> AB (JoinTable) <-> B (many)

The tables look like this

A
--
ID
BREF
...

B
--
ID
...

AB
--
A_BREF      (foreign key to a reference column in A which is NOT the id)
B_ID

I would like to define a unidirectional one-to-many relationship for class A.

class A {

 private List<B> bs;

}

and did it like this:

<one-to-many name="bs">
    <join-table name="ab">
        <join-column name="a_bref">
            <referenced-column-name name="bref" />
        </join-column>
        <inverse-join-column name="b_id">
            <referenced-column-name name="id" />
        </inverse-join-column>
    </join-table>
</one-to-many>

Althoug this does not force an error it is not working. The problem is that the join table does not work on the ID column of A. The query to select the “B” entities works with the A.ID column value instead of the A.BREF column value to select the entities.

(How) can I make this mapping work (I use eclipselink 2.2.0)?

Thanks for any suggestion!


EDIT:

After looking at a link provided in @SJuan76 answer I slightly modified my mapping to

<one-to-many name="bs">
    <join-table name="ab">
        <join-column name="a_bref" referenced-column-name="bref" />
        <inverse-join-column name="b_id" referenced-column-name="id" />
    </join-table>
</one-to-many>

This now causes the following errors (tested with eclipselink 2.1.0 and 2.2.0)

eclipselink 2.1.0

Exception Description: The parameter
name [bref] in the query’s selection
criteria does not match any parameter
name defined in the query.

eclipselink 2.2.0

Exception Description: The reference
column name [bref] mapped on the
element [field bs] does not
correspond to a valid field on the
mapping reference.

By the way – if I remove the referenced-column-name="bref" from the definition I get the same exception for the referenced-column-name="id" on the inverse-join-column element. So I doubt that I have understood referenced-column-name correct. I used it to specify the database column name of the tables which are related to the join table. Is this correct?


SOLUTION:

The final error in my szenario was that I did not have the BREF field definied in my class

class A {
    private long bref; // missing !
    private List<B> bs; 
}

and in my orm.xml mapping file for this class

<basic name="bref">
    <column name="bref" />
</basic>

I was not aware that I have to define the used join mapping referenced-column-name attributes somewhere in my mapping classes (as I also did not have the join-table itself or the name attributes of join-column/inverse-join-column mapped to a class or class members.)

Also the tip to check the case issue was helpful for me. I feel now quite to verbose in specifying my mapping as I overwrite all default (uppercase) mappings with lowercase values. As my database is not case sensitive I will use upper case notation if special mapping is needed to go with the default.

+1 for all!

  • 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-05-23T04:34:44+00:00Added an answer on May 23, 2026 at 4:34 am

    Can you try defining the field as “BREF” or the same exact case used if you defined it on the attribute mapping, or you can try setting the eclipselink.jpa.uppercase-column-names persistence property to true. This is likely the issue with “id” when referenced-column-name=”bref” is removed, since it is likely the field in the entity defaults to “ID”.

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

Sidebar

Related Questions

I would like to evaluate .NET as a development platform for a desktop application.
I would like to use a language that I am familiar with - Java,
I would like to evaluate an environment variable and set the result to a
We would like to evaluate whether the SVN protocol works better for our team
I am using a SaveFileDialog and would like to evaluate whether a file meets
I developed a small nifty webserver in C and would like to evaluate its
I have an array with 16 elements. I would like to evaluate these to
we experience with some regularity contention on a database table, and would like to
I would like to update my SQL lite database with the native update-method of
When you push submit it would seem like it should evaluate the header in

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.