Welcome Guest  |  Register  |  Login
Login Name Password
  Search  
  Index  | Recent Threads  | Unanswered Threads  | Who's Online  | Help


Quick Go »

No member browsing this thread
Thread Status: Active
Total posts in this thread: 7
[ Jump to Last Post ]
Post new Thread
Author
Previous Thread This topic has been viewed 1782 times and has 6 replies Next Thread
Male nlmarco
Expert
Member's Avatar

Germany
Joined: Mar 15, 2004
Post Count: 766
Status: Offline
Reply to this Post  Reply with Quote 
SQL error in MySQL > 4.1.13

Hello Andy & Erik,

first of all: Thanks a lot for JPOX 1.1.0 final!!! Great work!

We encountered a strange problem with some queries: On MySQL 4.1.13 it works fine, but on higher versions (e.g. the 4.1 version distributed with Ubuntu or the 5.0.18 that comes with SuSE 10.1), I get the following exception:
java.sql.SQLException: Unknown column 'THIS.ORGANISATION_ID' in 'on clause'
I tracked it down (here is the complete query) and found out that it's the behaviour concerning cross joins. JPOX generates a query like this:
SELECT ...
FROM table1 `this`
LEFT JOIN table2 `...` on ...
,
table 3 `...`,
LEFT JOIN table4 `...` on `this` .`...` = ...
The problem is the second green `this`, as it is separated from the first part by the green comma and not found anymore by MySQL. It seems to me, MySQL has changed the handling of aliases somewhere after version 4.1.13.

But if I understand it correctly, the solution is very easy: The green comma can be replaced by a CROSS JOIN and in fact this works fine on MySQL 4.1.13 and newer versions (here is the complete query after replacing).

I took a look into the MySQLAdapter class, but unfortunately I didn't find how to influence QueryStatement there. At least, I assume that QueryStatement.stmtCandidateSetsSeparator should be "CROSS JOIN" - but probably only for those SQL servers that support "CROSS JOIN". Is my assumption correct? Could you please tell me, how to fix that problem?

Best regards, Marco smile
----------------------------------------
Best regards, Marco smile
jfire: free erp, crm, scm and more
[May 15, 2006 6:57:42 PM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
Male nlmarco
Expert
Member's Avatar

Germany
Joined: Mar 15, 2004
Post Count: 766
Status: Offline
Reply to this Post  Reply with Quote 
Re: SQL error in MySQL > 4.1.13

QueryStatement.stmtCandidateSetsSeparator is a char and thus I cannot simply set " CROSS JOIN " sad
----------------------------------------
Best regards, Marco smile
jfire: free erp, crm, scm and more
[May 15, 2006 7:01:53 PM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
Male erik
Expert
Member's Avatar

Belgium
Joined: Mar 12, 2004
Post Count: 2991
Status: Offline
Reply to this Post  Reply with Quote 
Re: SQL error in MySQL > 4.1.13

Marco, please raise a bug
----------------------------------------
Erik Bengtson


[May 15, 2006 7:08:25 PM] Show Printable Version of Post    View Member Profile    Send Private Message    Hidden to Guest [Link] Report threatening or abusive post: please login first  Go to top 
Male nlmarco
Expert
Member's Avatar

Germany
Joined: Mar 15, 2004
Post Count: 766
Status: Offline
Reply to this Post  Reply with Quote 
Re: SQL error in MySQL > 4.1.13

Hello Erik,

thanks for your quick response! I created an issue: http://www.jpox.org/servlet/jira/browse/CORE-2824

And I tried a bit further: I replaced
protected char stmtCandidateSetsSeparator = ',';
by
protected String stmtCandidateSetsSeparator = " CROSS JOIN ";
in the class QueryStatement and it works fine for me now. Hence, I would like to fix the bug correctly and check it into CVS.

Therefore: Shall I replace char by String for the field QueryStatement#stmtCandidateSetsSeparator, create a new class named MySQLQueryStatement (I saw that there are already some in org.jpox.rdbms.query) and override the two newQueryStatement(...) methods in the MySQLAdapter? Do I need to override more methods than just these two?

... or do all database servers that JPOX currently supports accept CROSS JOIN and we can change it globally?

Best regards, Marco smile
----------------------------------------
Best regards, Marco smile
jfire: free erp, crm, scm and more
[May 15, 2006 8:12:24 PM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
Male erik
Expert
Member's Avatar

Belgium
Joined: Mar 12, 2004
Post Count: 2991
Status: Offline
Reply to this Post  Reply with Quote 
Re: SQL error in MySQL > 4.1.13

Marco,

Your change is good, however, I'm making it less "relational".

The stmtCandidateSetsSeparator has dissapeared and I created dba.cartesianProduct method, so it is responsible to generate the

CROSS JOIN "Y"

Also, the class TableExpression was renamed to LogicSetExpression
----------------------------------------
Erik Bengtson


[May 15, 2006 8:40:05 PM] Show Printable Version of Post    View Member Profile    Send Private Message    Hidden to Guest [Link] Report threatening or abusive post: please login first  Go to top 
Male erik
Expert
Member's Avatar

Belgium
Joined: Mar 12, 2004
Post Count: 2991
Status: Offline
Reply to this Post  Reply with Quote 
Re: SQL error in MySQL > 4.1.13

fixed in CVS
----------------------------------------
Erik Bengtson


[May 15, 2006 9:01:41 PM] Show Printable Version of Post    View Member Profile    Send Private Message    Hidden to Guest [Link] Report threatening or abusive post: please login first  Go to top 
Male nlmarco
Expert
Member's Avatar

Germany
Joined: Mar 15, 2004
Post Count: 766
Status: Offline
Reply to this Post  Reply with Quote 
Re: SQL error in MySQL > 4.1.13

Hello Erik,

thanks a lot for fixing it! I checked it out already and it seems to work fine.

Best regards, Marco smile
----------------------------------------
Best regards, Marco smile
jfire: free erp, crm, scm and more
[May 15, 2006 11:00:47 PM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
[ Jump to Last Post ]
Show Printable Version of Thread  Post new Thread