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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T00:35:03+00:00 2026-05-18T00:35:03+00:00

I have a 2 classes that share a UUID and are uni-directionally mapped. I

  • 0

I have a 2 classes that share a UUID and are uni-directionally mapped. I use the UUID to group related rows, and this group shares many details (this is just an example):

@Entity @Table
class Something {
   @Id @Column("something_id")
   private Long id;

   private String uuid = UUID.randomUUID().toString();

   @OneToMany
   @JoinColumn("uuid")
   private List<Detail> details = new LinkedList<Detail>(); 
}

@Entity @Table
class Detail {
   @Id @Column("detail_id")
   private Long id;
   private String value;
   private String uuid;
}

I’m attempting to use Criteria:

Criteria c = getSession().createCriteria(Something.class).createAlias("details", "detail").add(Restrictions.eq("detail.value", someValue));

This is all fine and dandy, but I’m not getting results because of the join:

inner join DETAIL d1_ on this_.SOMETHING_ID=d1_.UUID 

Is it possible to specify:

inner join DETAIL d1 on this_.UUID=d1.UUID

I would have expected the join to use the @JoinColumn annotaiton to find the column to join on. I see that I can specify a join type, but I don’t see a way to specify the actual column.

  • 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-18T00:35:03+00:00Added an answer on May 18, 2026 at 12:35 am

    I would have expected the join to use the @JoinColumn annotation to find the column to join on. I see that I can specify a join type, but I don’t see a way to specify the actual column.

    The join is using the JoinColumn annotation since it’s joining on d1_.UUID. However, because you didn’t specify the referencedColumnName element, the foreign key is assumed to refer to the primary key of the referenced table (this_.SOMETHING_ID), hence the obtained result.

    In other words, try this:

    @OneToMany
    @JoinColumn(name="uuid", referencedColumnName="uuid")
    private List<Detail> details = new LinkedList<Detail>(); 
    

    I’m not sure to understand the benefit but let’s say it’s another story.

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

Sidebar

Related Questions

I have classes like the following. That is many classes with the same few
I have two different classes that share a common interface. Although the functionality is
I have multiple classes (controllers) that share a huge chunk of code with each
The initialization process of a group of classes that share a common parent can
I have many many adhoc and general utility classes that I have written over
I have some classes that are used as Singletons. They share some basic functionality
I have many classes inheriting the Page class. They share the same update_ended method
I have classes that are named exactly the same across different plug-ins that I
I have classes that are needed in both my web service and my server.
I have custom classes that I currently instantiate within App.xaml as resources. I want

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.