Win a copy of Microservices Testing (Live Project) this week in the Spring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

Hibernate generating queries with duplicate columns

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am facing a issue with the query generated by hibernate to load from database.

SELECT this_.id AS id25_1_,
this_.name AS name25_1_,
offices2_.legal_entity_id AS legal3_3_,
offices2_.id AS id3_,
offices2_.id AS id27_0_,

offices2_.name AS name27_0_,
offices2_.legal_entity_id AS legal3_27_0_
FROM cm.legal_entities this_
LEFT OUTER JOIN cm.offices offices2_ ON this_.id = offices2_.legal_entity_id;

Why is hibernate generating query with duplicate reference to offices2_.id ?

My hbm file for legal_entities table is -



And hbm for office is -




Thanks in advance,
Amey
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No idea I'm afraid. Does it cause a problem?
 
Amey Dhoke
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

This is not causing any problem, just that I am curious to know.

Looks like the way hibernate code works is, it adds columns from the joined table and it adds the same columns again if type join is LEFT_OUTER_JOIN. (The logic is in selectFragment() method of OneToManyPersister class)
Looks like it is a bug but im not sure if there is any other purpose behind this logic.

Any idea ?


Thanks,
Amey
 
I child proofed my house but they still get in. Distract them with this tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic