Forums Register Login

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

+Pie Number of slices to send: Send
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?
+Pie Number of slices to send: Send
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
That feels good. Thanks. Here's a tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 9365 times.
Similar Threads
Integrity constraint in Hibernate
jpa problem
Many to One instead of One to One relationship
Outer join between 3 entities in HQL
EntityManager.persist(obj) is not actually storing the object in Database
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 22:57:01.