You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-dev@db.apache.org by br...@apache.org on 2003/05/23 18:52:30 UTC
cvs commit: db-ojb/src/java/org/apache/ojb/broker/accesslayer/sql SqlQueryStatement.java
brj 2003/05/23 09:52:30
Modified: src/java/org/apache/ojb/broker/accesslayer/sql
SqlQueryStatement.java
Log:
fixed problems with user defined alias and m:n relationships
Revision Changes Path
1.39 +24 -20 db-ojb/src/java/org/apache/ojb/broker/accesslayer/sql/SqlQueryStatement.java
Index: SqlQueryStatement.java
===================================================================
RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/accesslayer/sql/SqlQueryStatement.java,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -r1.38 -r1.39
--- SqlQueryStatement.java 13 May 2003 15:23:29 -0000 1.38
+++ SqlQueryStatement.java 23 May 2003 16:52:30 -0000 1.39
@@ -149,6 +149,9 @@
if (sp == -1)
{
+ // BRJ ignore alias for simple attributes
+ tableAlias = getRoot();
+/*
if (aUserAlias == null)
{
tableAlias = getRoot();
@@ -161,6 +164,7 @@
tableAlias = getRoot();
}
}
+*/
}
else
{
@@ -716,8 +720,7 @@
boolean outer = useOuterJoins;
- curr = getTableAliasForPath(aPath, aUserAlias);
-
+ curr = getTableAliasForPath(aPath, aUserAlias);
if(curr != null)
{
@@ -762,23 +765,24 @@
}
else
{
- String mnAttrPath = attrPath + "*";
- indirect = getTableAliasForPath(mnAttrPath, aUserAlias, aPath);
- if (indirect == null)
- {
- indirect = createTableAlias(cod.getIndirectionTable(), mnAttrPath, aUserAlias, aPath);
-
- // we need two Joins for m:n
- // 1.) prev class to indirectionTable
- prevKeys = prev.cld.getPkFields();
- join = new Join(prev, prevKeys, indirect, cod.getFksToThisClass(), outer, attr + "*");
- prev.addJoin(join);
-
- // 2.) indirectionTable to the current Class
- prev = indirect;
- prevKeys = cod.getFksToItemClass();
- keys = cld.getPkFields();
- }
+ String mnAttrPath = attrPath + "*";
+ String mnPath = aPath + "*";
+ String mnUserAlias = (aUserAlias == null ? null : aUserAlias + "*");
+ indirect = getTableAliasForPath(mnAttrPath, mnUserAlias, mnPath);
+ if (indirect == null)
+ {
+ indirect = createTableAlias(cod.getIndirectionTable(), mnAttrPath, mnUserAlias, mnPath);
+
+ // we need two Joins for m:n
+ // 1.) prev class to indirectionTable
+ prevKeys = prev.cld.getPkFields();
+ join = new Join(prev, prevKeys, indirect, cod.getFksToThisClass(), outer, attr + "*");
+ prev.addJoin(join);
+ }
+ // 2.) indirectionTable to the current Class
+ prev = indirect;
+ prevKeys = cod.getFksToItemClass();
+ keys = cld.getPkFields();
}
}
else