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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T07:09:11+00:00 2026-05-11T07:09:11+00:00

Is it possible in plain JPA or JPA+Hibernate extensions to declare a composite key,

  • 0

Is it possible in plain JPA or JPA+Hibernate extensions to declare a composite key, where an element of the composite key is a sequence?

This is my composite class:

@Embeddable public class IntegrationEJBPk implements Serializable {      //...       @ManyToOne(cascade = {}, fetch = FetchType.EAGER)     @JoinColumn(name = 'APPLICATION')     public ApplicationEJB getApplication() {         return application;     }       @Column(name = 'ENTITY', unique = false, nullable = false, insertable = true, updatable = true)     public String getEntity() {         return entity;     }      @GeneratedValue(strategy = GenerationType.AUTO, generator = 'INTEGRATION_ID_GEN')     @SequenceGenerator(name = 'INTEGRATION_ID_GEN', sequenceName = 'OMP_INTEGRATION_CANONICAL_SEQ')     @Column(name = 'CANONICAL_ID', unique = false, nullable = false, insertable = true, updatable = true)     public String getCanonicalId() {         return canonicalId;     }      @Column(name = 'NATIVE_ID', unique = false, nullable = false, insertable = true, updatable = true)     public String getNativeId() {         return nativeId;     }      @Column(name = 'NATIVE_KEY', unique = false, nullable = false, insertable = true, updatable = true)     public String getNativeKey() {         return nativeKey;     }      //... } 

I already supply the values for application, entity, nativeId and nativeKey. I want to construct an entity like the one below:

IntegrationEJB i1 = new IntegrationEJB(); i1.setIntegrationId(new IntegrationEJBPk()); i1.getIntegrationId().setApplication(app1); i1.getIntegrationId().setEntity('Entity'); i1.getIntegrationId().setNativeId('Nid'); i1.getIntegrationId().setNativeKey('NK'); 

And when I call em.persist(i1), I want that the canonicalId is generated and the integration is inserted.

Is this possible? If so, what’s the simple way? (I prefer not to use application-provided keys or native sql).

  • 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. 2026-05-11T07:09:12+00:00Added an answer on May 11, 2026 at 7:09 am

    I believe that this is not possible with plain JPA.

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

Sidebar

Related Questions

Possible Duplicate: Plain english explanation of Big O I'd imagine this is probably something
It is possible in plain Java to override a method of a class programmatically
I don't know if this is possible, but having code in plain C, is
Possible Duplicate: How do I calculate someone's age in C#? Maybe this could be
Possible Duplicate: Plain English explanation of Big O I can't find any sufficient help
Possible Duplicate: Plain English explanation of Big O I know Big O notation is
Is it possible to use jQuery with the HTML5 <canvas> element? Or do I
A window should stay on top of all other windows. Is this somehow possible
Possible Duplicate: Using an ORM or plain SQL? Would you elect to use an
Possible Duplicate: What does the term Plain Old Java Object(POJO) exactly mean? I know

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.