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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T03:32:50+00:00 2026-05-20T03:32:50+00:00

I am trying to generate a unidirectional one-to-many mapping between two JPA entities. In

  • 0

I am trying to generate a unidirectional one-to-many mapping between two JPA entities. In my ChatRoom class, I have a Vector<User> type object that represents Users in a ChatRoom. I am trying to create a one-to-many mapping, based on userId (in the User class). Here is my sample code:

@Entity
public class ChatRoom {
    @Id
    @GeneratedValue
    private int chatRoomID;

    @OneToMany(mappedBy="userID")
    private Vector<User> users;

    // A no-argument constructor is required for EclipseLink to instantiate the persistence object properly.
    public ChatRoom() {}

    // Getter/Setter section
}

Here is the User class:

@Entity
public class User {
    @Id
    @GeneratedValue
    private int userID;

    private String username;

    // Getter/Setter section
}

When I try to generate the tables from these entities in Eclipse, I get the following error:

Internal Exception: javax.persistence.PersistenceException: Exception [EclipseLink-28018] (Eclipse Persistence Services - 2.0.2.v20100323-r6872): org.eclipse.persistence.exceptions.EntityManagerSetupException
Exception Description: Predeployment of PersistenceUnit [ChatJPA] failed.
Internal Exception: Exception [EclipseLink-7244] (Eclipse Persistence Services - 2.0.2.v20100323-r6872): org.eclipse.persistence.exceptions.ValidationException
Exception Description: An incompatible mapping has been encountered between [class iosoa.entity.ChatRoom] and [class iosoa.entity.User]. This usually occurs when the cardinality of a mapping does not correspond with the cardinality of its backpointer.
    at org.eclipse.persistence.exceptions.PersistenceUnitLoadingException.exceptionSearchingForPersistenceResources(PersistenceUnitLoadingException.java:126)

Do you have any ideas on how to resolve this problem? Thanks for your help.

  • 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-20T03:32:51+00:00Added an answer on May 20, 2026 at 3:32 am

    A few things,

    Your mappedBy is wrong, a mappedBy for a OneToMany must be a ManyToOne. I would recommend you add the ManyToOne back, or use a @JoinTable, if you do not wish to, then you could use an @JoinColumn and no mappedBy.

    Vector is not valid in JPA, you must use List, Set or Map. You can still use a Vector as your implementation class. If you really want to use Vector, then EclipseLink will support this, but you must make your mapping EAGER.

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

Sidebar

Related Questions

I'm trying to generate a report of the activities that users have done within
I have been trying to generate report as per age differences of different months
I have an application in which I am trying to implement ManyToMany relation between
i am trying to generate the following list in asp.net? <div class=items> <!-- 1-5
Im trying to generate n unique random numbers between 1 and max I tried
I'm trying to generate a list of events that a user is attending. All
I'm trying to generate a SQL query that can join two tables together and
I'm trying to generate a report base on pre defined dates(cutoff dates). I have
I'm trying to implement a model for private messages between two or more users.
Trying to generate random digits with SecureRandom class of rails. Can we create 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.