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

@Entity @Table(name = J_CNTRY) public class CountryEntity { @Id @GeneratedValue(strategy = GenerationType.TABLE, generator =
Imagine, an Event entity references a Status Entity: @Entity @Table(name = event) public class
I have an entity class called Group and NetBeans warns me The entity table
Category EJB package session; import com.Entity.Category; import javax.ejb.Stateless; import javax.persistence.EntityManager; import javax.persistence.PersistenceContext; Item EJB
I am using a hibernate sequencegenerator to auto-generate unique values for my primary key
My object model is given below and would like your inputs on the number
I don't know how to phrase the question properly so sorry in advance. Using
i'm trying to check whether my forms(Zend_Form) are being well processed and display whatever
I have 4 persistent classes which all have the same fields (exactly) the only
I am trying to implement DAOs to work with Spring Security database authentication 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.