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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T16:28:06+00:00 2026-06-17T16:28:06+00:00

I have an entity class userdetails which has the username, userid (numeric) and password

  • 0

I have an entity class userdetails which has the username, userid (numeric) and password fields, with username and userid forming a composite primary key. This is negotiable, and possibly unimportant to the main problem.

I have another class, connectiontable, which has userid as the primary key. The sql code used to generate the relevant tables is as follows:

create table usertable
(
userid int NOT NULL GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1),
username varchar(128) NOT NULL UNIQUE,
password varchar(128) NOT NULL, 
CONSTRAINT USER_PK PRIMARY KEY(username, userid)

);

That’s the sql code for usertable. The following is for connectiontable

create table connectiontable
(
userid int not null,
username varchar(128) not null,
connections varchar(32670) not null,

CONSTRAINT CONNECTION_PK PRIMARY KEY(username, userid),
CONSTRAINT CONNECTION_FK FOREIGN KEY(username,userid) REFERENCES usertable(username,userid) 
);

There are a bunch of other things in connectiontable, but those are irrelevant. I use netbeans 7.2.1 and Jave EE6. I use the ‘create entities from database entries’ but for some reason, I don’t have a getter and setter for either userid or username. They are in connectiontablePK, but I can’t seem to make use of that. For example, when I generate the jsf pages, I want to be able to do something like:

Connectiontable con = new Connectiontable();
con.getUsername();

But it complains because it can’t find that method in connectiontable.java.

Can anyone advise me why this is the case, and how I can solve it? 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-17T16:28:07+00:00Added an answer on June 17, 2026 at 4:28 pm

    … You’re not posting the Java code, which I suspect would help but:

    Anytime in JPA when you have a composite primary key, you have to have an ’embedded’ primary-key class. I suspect you have a class definition similar to the following:

    @Embeddable
    public class UserNameId {
        private int userid;
        private String username;
    }
    

    And then usertable and connectiontable both contain the following (or similar):

    @Embedded
    @Id
    private UserNameId userNameId;
    

    … So you should expect a getter/setter for userNameId, but not the embedded fields, like you expect.

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

Sidebar

Related Questions

I have an entity UserDetails which has the following variables: String userId String userName
I have entity that has a version. It has composite primary key where one
I have an entity class that has 10 fields. I am using MS Validation
I have an entity class with the following annotation on its primary key: @GeneratedValue(strategy
I have an entity class which has 3 columns; entityType, entityID and EntityText. I
I have a User class marked as entity which also implements UserDetails. I want
In my business model I have Entity class (IPoint interface ) that has a
I have an Entity class, which contains 3 pointers: m_rigidBody, m_entity, and m_parent. Somewhere
I have an entity class. This entity has lots of properties and entity's data
I have an entity class, correctly defined in a managed context. This class has

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.