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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T22:55:43+00:00 2026-05-18T22:55:43+00:00

I have a relationship as follows using Hibernate annotations, this is what I tried:

  • 0

I have a relationship as follows using Hibernate annotations, this is what I tried:

public class Job{

...

@OneToMany(cascade = CascadeType.ALL)
@JoinTable(name = "jobs_resource_locations")
@ForeignKey(name = "job_inputs_fk")
@Index(name="job_inputs_fk")
private List<FileSystemLocation> inputs;

This sort of thing works nicely on ManyToOne like so:

@ManyToOne
@JoinColumn(name = "service_call_id", referencedColumnName = "id")
@ForeignKey(name = "job_service_call_fk")
@Index(name = "job_service_call_fk")
private ServiceCall serviceCall;

I wanted to ensure that the foreign key gets indexed on PostgreSQL and that the schema looks similar on MySQL, hence the @ForeignKey and @Index with the same name (MySQL always creates an index with the same name as the FK).

I cannot create the index on the inverse side because FileSystemLocation is unaware of the relationship. Hence the JoinTable.

The former example fails since Hibernate finds no column in Job to index:

org.hibernate.MappingException: Unable to find logical column name from physical name null in table jobs

Does anyone know how to create indices on JoinTable foreign keys using Hibernate?

  • 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-18T22:55:44+00:00Added an answer on May 18, 2026 at 10:55 pm

    It’s not exactly the answer you would like to receive, but this is the expected behavior. In other words: this is not supported. See the following JIRA for more details:

    https://hibernate.atlassian.net/browse/HHH-4263

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

Sidebar

Related Questions

I have a POCO class as follows public class Category { public int ID
I am using JPA 2.0 and hibernate. I have a User class and a
Assume that I have two entities as follows: class Blog { public Blog() {
Ok, I have a relationship between People, Users and Employees such that All Employees
I have a OneToMany relationship in an SQL Server database. When I add the
I have a many to many relationship as follows: Products ProductID Description ProductFeatures ProductFeatureID
I have an entity class: Cabbage.java package womble; public class Cabbage { private int
I have a many to many relationship as follows: Products Table: ProductID Description ProductFeatures
I have two entities, Job and Language , in a many-to-one relationship. The mapping
I have a relationship table with followed_id, follower_id, and status. I am using has

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.