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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T19:02:35+00:00 2026-05-17T19:02:35+00:00

Using the EclipseLink JPA2 implementation (not sure if it’s the same with the Hibernate

  • 0

Using the EclipseLink JPA2 implementation (not sure if it’s the same with the Hibernate implementation)

I have a simple structure where an Organization entity has contracts. Here’s the sql I exported from postgres to create the Organization

CREATE TABLE organization (
    key bigint NOT NULL,
    version integer
);

If I specify the Contract side of the Organization like this:

@ManyToOne( optional=false )
@JoinColumn( name="organization_key", referencedColumnName="key" )
private Organization organization;

and then dump the schema I get this.

CREATE TABLE contract ( 
    key bigint NOT NULL, 
    version integer, 
    organization_key character varying(255), 
);

It doesn’t make sense to me that it would use a character varying(255) field for the reference to the organization key. I know I can use the columnDefinition as follows:

@ManyToOne( optional=false )
@JoinColumn( name="organization_key", referencedColumnName="key", columnDefinition="bigint NOT NULL" )
private Organization organization;

to get the bigint type instead of the character type.

Is it unrealistic for me to expect it to get the correct column type? Am I using it wrong, or do I have the wrong expectations? Is it expected for me to have to use the columnDefinition each time?

Update:
Here’s the relevant info from the Organization entity

@Entity
@Table( name = "organization" )
@SequenceGenerator( name = "ORGANIZATION_SEQ_GEN", sequenceName = "ORGANIZATION_SEQUENCE" )
public class Organization
        implements DataObject<Long>
{

    /**
     * key for this instance. Should be managed by JPA provider.
     */
    @Id
    @GeneratedValue( strategy = GenerationType.SEQUENCE, generator = "ORGANIZATION_SEQ_GEN" )
    private Long key;

    /**
     * JPA version column
     */
    @Version
    protected int version;

    /**
     * All contracts for this organization
     */
    @OneToMany(mappedBy="organization" )
    @OrderBy( "endDate DESC" )
    private List<Contract> contracts;

    ... getters and setters        
 }

And here’s the Contract entity

@Entity
@Table( name = "contract" )
@SequenceGenerator( name = "CONTRACT_SEQ_GEN", sequenceName = "CONTRACT_SEQUENCE" )
public class Contract
        implements DataObject<Long>
{

    /**
     * key for this instance. Should be managed by JPA provider.
     */
    @Id
    @GeneratedValue( strategy = GenerationType.SEQUENCE, generator = "CONTRACT_SEQ_GEN" )
    private Long key;

    /**
     * Organization that owns this contract, required.
     */
    @ManyToOne( optional=false )
    @JoinColumn( name="organization_key", referencedColumnName="key" )
    private Organization organization;

    /**
     * JPA version column
     */
    @Version
    protected int version;

    ... getters and setters
}
  • 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-17T19:02:35+00:00Added an answer on May 17, 2026 at 7:02 pm

    Is it unrealistic for me to expect it to get the correct column type?

    No, it’s not unrealistic and the current result is clearly unexpected.

    Am I using it wrong, or do I have the wrong expectations?

    Your mappings doesn’t look wrong. Could you just try the following and confirm that you get the same result (I’m simply omitting the referencedColumnName that you should not have to define anyway)?

    @Entity
    @Table( name = "contract" )
    @SequenceGenerator( name = "CONTRACT_SEQ_GEN", sequenceName = "CONTRACT_SEQUENCE" )
    public class Contract implements DataObject<Long> {
        @Id
        @GeneratedValue( strategy = GenerationType.SEQUENCE, generator = "CONTRACT_SEQ_GEN" )
        private Long key;
        ...
        @ManyToOne( optional=false )
        @JoinColumn( name="organization_key" )
        private Organization organization;
        ...
    }
    

    I don’t have PostgreSQL installed, can’t try myself.

    Is it expected for me to have to use the columnDefinition each time?

    No.

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

Sidebar

Related Questions

I am using eclipselink for JPA . I have an entity, which has a
I have entity model like this (using EclipseLink and JPA 2.0): @Entity class A
I'm using JPA2 with EclipseLink implementation. I'm simply trying to save the current Date
I am using JPA2.0 ( Eclipselink ) to interact with DB and I have
I'm using JPA 2.0, more precisely Eclipselink. Here's my problem: I have an entity
I have been developing my web-app using JPA 2.0 implementation EclipseLink 2.2.0. I finally
I'm using the EclipseLink implementation of the JPA 2.0 which allows pessimistic locking. I
Using Eclipselink/MOXy 2.3 i have following usecase in marshalling to XML: abstract class MyAbstract
We are using Eclipselink for ORM, but we have a need for some more
I'm currently moving a (working) app from using EclipseLink to Hibernate JPA, mostly it's

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.