• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to join two tables on columns that have different names?

 
Ranch Hand
Posts: 37
IntelliJ IDE Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi everyone,

I'm trying to join two tables that have different column names.





These two tables need to be joined on OWORD_CODE.CODE = OWORD_LANGUAGE = RESOURCE_KEY, but I'm have difficulties doing that. If the columns were named the same, it works fine.

Here is my class for the OWORD_CODE table...


Here is my class for the OWORD_LANGUAGE table...


Here is the code I'm using to retrieve the data...


I get the following error...

ERROR [JDBCExceptionReporter] ORA-00904: "OWORDLANGU0_"."CODE": invalid identifier

and when I look at the logs, I see the select statement that was generated has the column code in the OWORD_LANGUAGE table, but that table does not have a column named code.




What am I doing wrong here?
 
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Steve,



The above mapping conveys to the Hibernate framework that in the OWORD_LANGUAGE table, there is a column with the name "CODE" that will be used for joining with OWORD_CODE table.

But you do not have "CODE" column in the OWORD_LANGUAGE.

So the solution is to specify that column of the OWORD_LANGUAGE that will contain the OWORD_CODE.CODE value.


Regards,
Naresh Waswani
 
reply
    Bookmark Topic Watch Topic
  • New Topic