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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T22:58:11+00:00 2026-06-13T22:58:11+00:00

I’m reading hibernate reference, they’re two elements in Hibernate: <join><any> . After reading it,

  • 0

I’m reading hibernate reference, they’re two elements in Hibernate: <join><any>. After reading it, I don’t know what the reference is talking about.

I don’t understand when to use join/any, what kind of scenarios are they suitable for? For <join/>: when setting “fetch”, when will hibernate use inner join, when will use outer join, when will use select? Which tables which columns are used? And for the example hibernate reference provided, it said:
<join table=”ADDRESS”> <key column=”ADDRESS_ID”/> <property name=”address”/> <property name=”zip”/> <property name=”country”/> </join>, then which column is used to join these two tables?

When setting fetch for <join>, it said:
fetch (optional – defaults to join): If set to join, the default, Hibernate will use an inner join to retrieve a <join> defined by a class(My question: Would anybody please give me an example to say: which is this class?) or its superclasses((My question: Would anybody please give me an example to say: which is this class?) ) and an outer join for a <join> defined by a subclass((My question: Would anybody please give me an example to say: which is this class?) ). If set to select then Hibernate will use a sequential select for a <join> defined on a subclass((My question: Would anybody please give me an example to say: which is this class?)), which will be issued only if a row turns out to represent an instance of the subclass((My question: Would anybody please give me an example to say: which is this class?)). Inner joins will still be used to retrieve a defined by the class and its superclasses((My question: Would anybody please give me an example to say: which is this class?) ).

In other words, I want to know what are all the classes said below:
fetch (optional – defaults to join): If set to join, the default, Hibernate will use an inner join to retrieve a <join> defined by a class or its superclasses and an outer join for a <join> defined by a subclass. If set to select then Hibernate will use a sequential select for a <join> defined on a subclass, which will be issued only if a row turns out to represent an instance of the subclass. Inner joins will still be used to retrieve a <join> defined by the class and its superclasses.

For <any>, what kind of scenarios is it suitable for?, would u please explain how it works? Is there anybody providing example and explaining this to me? Thanks.

  • 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-06-13T22:58:11+00:00Added an answer on June 13, 2026 at 10:58 pm
    • <join> is used to map one class two 2+ tables which have a one-to-one association over the primarykey/id

      Table A        Table B
      -------        -------
      id | name      a_id | status
      
      class Foo
      {
          private int id;
          private string name;
          private string status;
      }
      
      <class name="Foo">
        <id name="id"/>
        <property name="name"/>
        <join table="B">
          <key column="a_id"/>
          <property name="status"/>
        </join>
      </class>
      
    • <any> is used to map a polymorphic reference e.g. a contact can reference a User or a Company it belongs to. So it uses two columns: one the id of Company/User and a second to store the type of the reference e.g. “user” or “company”. The advantage is that it knows the type (and table) of the referenced entity without the need to look into all possible tables

      Table Users         Table Companies
      ----------          -------------
      id | name           id | trademark
      
      Table Contacts
      -----------------------
      id | text | owner_id | owner_type
      
      class User/Company implements HasContacts
      {
          private int id;
          private string name/trademark;
          private Set<Contact> contacts;
      }
      
      class Contact
      {
          private int id;
          private string text;
          private HasContacts owner;
      }
      
      <class name="Contact">
        <id name="id"/>
        <property name="name"/>
        <any name="owner" id-type="System.Int64" meta-type="System.String">
          <meta-value value="user" class="User"/>
          <meta-value value="company" class="Company"/>
          <column name="owner_id"/>
          <column name="owner_type"/>
        </any>
      </class>
      
      <class name="User">
        <id name="id"/>
        <property name="name"/>
        <set name="contacts" where="owner_type='user'">
          <key column="owner_id"/>
          <one-to-many class="Contact"/>
        </set>
      </class>
      
      <class name="Company">
        <id name="id"/>
        <property name="trademark"/>
        <set name="contacts" where="owner_type='company'">
          <key column="owner_id"/>
          <one-to-many class="Contact"/>
        </set>
      </class>
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am reading a book about Javascript and jQuery and using one of the
I don't have much knowledge about the IPv6 protocol, so sorry if the question
I am trying to understand how to use SyndicationItem to display feed which is
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I've tracked down a weird MySQL problem to the two different ways I was
I know there's a lot of other questions out there that deal with this
Does anyone know how can I replace this 2 symbol below from the string

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.