Skip to content

Conversation

@kalinchan
Copy link

Credit to @luiseufrasio
Malformed SQL when using SecondaryTable & PrimaryKeyJoinColumn annotations

Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.6.8.payara-p3): org.eclipse.persistence.exceptions.DatabaseException Internal Exception: com.ibm.db2.jcc.am.SqlSyntaxErrorException: DB2 SQL Error: SQLCODE=-206, SQLSTATE=42703, SQLERRMC=T0.HCSO#, DRIVER=4.32.28 Error Code: -206 Call: SELECT t0.HDSO#, t1.HCSO#, t0.HDCUST, t0.HDYEAR, t0.HDRLSO, t1.HCUSER FROM SOHDS0 t0, SOHC t1 WHERE ((t0.HDSO# = ?) AND (t0.HCSO# = t0.HDSO#)) bind => [123] Query: ReadObjectQuery(name="readSalesOrder" referenceClass=FleetSalesOrder sql="SELECT t0.HDSO#, t1.HCSO#, t0.HDCUST, t0.HDYEAR, t0.HDRLSO, t1.HCUSER FROM SOHDS0 t0, SOHC t1 WHERE ((t0.HDSO# = ?) AND (t0.HCSO# = t0.HDSO#))")

The AND clause at the very end should have condition t1.HCSO# = t0.HDSO#

Copy link
Contributor

@rfelcman rfelcman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kalinchan
Copy link
Author

Hi, looking at Employee.java it doesn't seem to be the same use case.

In this situation, the following annotation is causing the error:

@SecondaryTable(name = "SOHC",//, schema = "OEF",
        pkJoinColumns = @PrimaryKeyJoinColumn(name = "HCSO#", referencedColumnName = "HDSO#"))

Is there a different place to write the test or is the Employee class still valid?

@rfelcman
Copy link
Contributor

rfelcman commented Oct 4, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants