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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T10:16:39+00:00 2026-05-27T10:16:39+00:00

I use Hibernate 3.6.8. Here is my tables: CREATE TABLE UTILIZATION ( ID BIGINT

  • 0

I use Hibernate 3.6.8. Here is my tables:

CREATE TABLE UTILIZATION (
ID BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY 
... 
FK_WORKCATEGORY SMALLINT,
CONSTRAINT PK_UTILIZATION PRIMARY KEY ( ID));

CREATE TABLE DB2ADMIN.WORKCATEGORY(
ID SMALLINT NOT NULL,
DESCRIPTION VARCHAR(50),
CONSTRAINT PK_WORKCATEGORY PRIMARY KEY(ID));

ALTER TABLE UTILIZATION ADD FOREIGN KEY (FK_WORKCATEGORY) REFERENCES WORKCATEGORY(ID); 

my Pojos:

@Entity
@Proxy(proxyClass=IWorkCategory.class)
@Table(name="WORKCATEGORY")
public class WorkCategory extends BoBase implements Serializable, IWorkCategory{

    @Id
    private Integer Id;
    private String description;

    @Override
    public Serializable getId() {
        return Id;
    }
    @Override
    public void setId(Serializable id) {
        Id = (Integer)id;
    }
    @Override
    public String getDescription() {
        return description;
    }
    @Override
    public void setDescription(String description) {
        this.description = description;
    }   
} 

@Entity
@Proxy(proxyClass=IUtilization.class)
@Table(name="UTILIZATION")
public class Utilization extends BoBase implements Serializable, IUtilization{

    @Id     
    @GeneratedValue(strategy=GenerationType.IDENTITY)
    private Long Id;    

    private WorkCategory workCategory;


    @ManyToOne(fetch=FetchType.LAZY, targetEntity=WorkCategory.class)
    @JoinColumn(name="FK_WORKCATEGORY", updatable=false, insertable=false)
    public WorkCategory getWorkCategory() {
        return workCategory;
    }


    public void setWorkCategory(WorkCategory workCategory) {
        this.workCategory = workCategory;
    }
}

As you can see the table Utilization refer to table WorkCategory by foreign key FK_WORKCATEGORY, but in Utilization pojo, i declare this property with the name workCategory.
When I run unit test for Utilization bo = UtilizationDAO.get(new Long(123)), the SQL is generated with the column UTILIZATIO0_.WORKCATEGORY, instead of FK_WORKCATEGORY.
I have put the @JoinColumn(name=”FK_WORKCATEGORY”, in the Utilization Pojo, but it doesn’t help.
Please help me to fix this error. Thanks in advance.

  • 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-27T10:16:40+00:00Added an answer on May 27, 2026 at 10:16 am

    That’s because you put your annotation on the getter rather than putting in on the field. Since the @Id annotation is put on a field, Hibernate expects all the annotations to be on fields.

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

Sidebar

Related Questions

I use Hibernate with Java. I have two tables which are associated with foreign
When designing a database to use MVCC (Multi-Version Concurrency Control), you create tables with
I'm attempting to use hibernate entity manager with mysql and glassfish. I'm getting the
Can I use Hibernate criteria to call a stored procudure?
I have some EJBs that use Hibernate to persist data to the database. I
How to get Hibernate session inside a Hibernate Interceptor? I'm trying to use Hibernate
I'm working on a project where we use Hibernate and JBoss 5.1. We need
I'm taking on the re-architecting of a pair of applications which use Hibernate in
I have a DB running on Oracle. I use Hibernate for data access. I
In our Spring application we use clustered Hibernate Search with ActiveMQ which sets up

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.