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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T09:03:36+00:00 2026-05-13T09:03:36+00:00

@Entity @Table(name = your_entity) public class YourEntityClass implements IEntity<Long> { @Id @SequenceGenerator(name = gen_test_entity2_id,

  • 0
    @Entity
    @Table(name = "your_entity")
    public class YourEntityClass implements IEntity<Long> {

        @Id
        @SequenceGenerator(name = "gen_test_entity2_id", sequenceName = "test_entity2_id_seq", allocationSize = 10)
        @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "gen_test_entity2_id")
        private Long id;

        @Column(name = "name", nullable = false, length = 64)
        private String name;

        /*
         * Create constructors, getters, setters, isEquals, hashcode, etc.
         */
    }

public interface IEntity<I extends Serializable> extends Serializable {

    /**
     * Property which represents id.
     */
    String P_ID = "id";

    /**
     * Get primary key.
     *
     * @return primary key
     */
    I getId();

    /**
     * Set primary key.
     *
     * @param id primary key
     */
    void setId(I id);
}

For the above code, my question is, why YourEntityClass need to pass Long in IEntity<Long>? Why not something else like IEntity<String>? Is it because the id is of type Long, and the getter of id must return the same type which we provided to IEntity?

  • 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-13T09:03:36+00:00Added an answer on May 13, 2026 at 9:03 am

    YourEntityClass puts <Long> in IEntity arbitrarily. Any type that implements Serializable can go there.

    After you’ve chosen the type for I, your getId() method has to return that same type.

    for example you could have another class that implements IEntity<String> and getId() in that case would have to return a String.

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

Sidebar

Related Questions

Consider the following code: @Entity @Table(name = a) public class A implements Serializable {
I have this piece of code: @Entity @Table(name = MOVERS) public class MOVers implements
I have the following mapping: @Entity @Table(name = Prequalifications) public class Prequalification implements Serializable
@Entity @Table(name = artist) public class Artist implements java.io.Serializable{ @Basic @Column(name = is_active,nullable=false) private
Hi every one I have these classe @Entity @Table(name = login, uniqueConstraints={@UniqueConstraint(columnNames={username_fk})}) public class
I have a domain class name DataList @Entity @Table(name = list_data) public class ListData
I have a simple class Role: @Entity @Table (name = ROLE) public class Role
Here is the BlogPost model : @Entity @Table(name = blog_posts) public class BlogPost extends
I have an entity like this: @Entity @Table(name = PLATFORM) public class Platform{ @Id
i have the following entity relationship: SideA: @Entity @Table(name = SideA) public class SideA

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.