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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:07:33+00:00 2026-05-26T18:07:33+00:00

My definition of class is like: @Entity @Table(name = items) public class Item {

  • 0

My definition of class is like:

@Entity
@Table(name = "items")
public class Item {
    @Id
    @GeneratedValue
    private long id;

    @Column(unique = true, nullable = false)
    private String url;

    @ManyToMany(fetch = FetchType.EAGER)
    @Fetch(FetchMode.JOIN)
    private Collection<Tag> tags;

    @Column(columnDefinition = "TEXT")
    private String text;
}

and when fetching with

 itemSession.createQuery("from Item i where i.url=?").setString(0, url)

two SQL queries are needed:

select item0_.id as id1_,
       item0_.text as text1_, 
       item0_.url as url1_ 
   from items item0_ 
   where item0_.url=?

select tags0_.items_id as items1_1_1_, 
       tags0_.tags_id as tags2_1_,
       tag1_.id as id0_0_, tag1_.lastCrawlTime as lastCraw2_0_0_, 
       tag1_.name as name0_0_ 
  from items_tags tags0_ inner join tags tag1_ on tags0_.tags_id=tag1_.id 
  where tags0_.items_id=?

How can I make it into one?

  • 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-26T18:07:34+00:00Added an answer on May 26, 2026 at 6:07 pm

    HQL ignores the fetching strategy specified in mappings. You should force the join using

    "from Item i join fetch i.tags where i.url=?"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given the following entity (some columns omitted from this long definition for brevity): @Table(name
I have a class like this public class Definition { public virtual string Name
Given a simple C# class definition like: [System.Windows.Markup.ContentProperty(PropertyOne)] public class SimpleBase { public string
Given a generic class definition like public class ConstrainedNumber<T> : IEquatable<ConstrainedNumber<T>>, IEquatable<T>, IComparable<ConstrainedNumber<T>>, IComparable<T>,
Let's say I have an object who's class definition looks like: class Command: foo
given this class definition: public class Frame { IFrameStream CapturedFrom; } I want implement
Lets assume following classes definition: public class A { public final static String SOME_VALUE;
So I've got a class like this: public class A { internal A(int i)
Why I need to load the class definition like : Class.forName(ClassName); What is the
Let's say I have a class definition like so: class Foo def init(val) @val

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.