You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@empire-db.apache.org by "Romain Gallet (JIRA)" <em...@incubator.apache.org> on 2010/08/03 14:40:17 UTC

[jira] Created: (EMPIREDB-82) Cloning does not work if DBTable's column (DBColumn) are declared final (as per shipped examples). Causing table alias in resulting SQL queries to be wrong

Cloning does not work if DBTable's column (DBColumn) are declared final (as per shipped examples). Causing table  alias in resulting SQL queries to be wrong
------------------------------------------------------------------------------------------------------------------------------------------------------------

                 Key: EMPIREDB-82
                 URL: https://issues.apache.org/jira/browse/EMPIREDB-82
             Project: Empire-DB
          Issue Type: Bug
    Affects Versions: empire-db-2.0.6-incubating
         Environment: Linux +  Glassfish 3.0.3 + JDK 1.6.0_21 + Archlinux
            Reporter: Romain Gallet


Hello,

For a given application, I needed to join a table LOCATION to itself. The definiftion is:

@Component("airportsDatabase")
public class Airports extends DBDatabase {

    public static class Location extends DBTable {

        public DBTableColumn ID;
        [...]
  
        public Location(DBDatabase db) {
            super("location", db);

            ID = addColumn("ID", DataType.INTEGER, 10, DataMode.NotNull);
            [...]
      }

      public final Location LOCATION = new Location(this);

      public Airports() {
    }
}

So LOCATION is my primary table object, declared at compile time. At runtime, I clone it like that:

Airports.Location LOCATION_2 = (Airports.Location) db.LOCATION.clone();

In org.apache.empire.db.DBTable.clone(), line 119, the Field is used to set the clone's fields set to the new "newCol" (line 108) which itself as a reference to "clone". The problem is that because "ID" (as shown above) is final, the Field.set() triggers an exeption, caught line 120.

The problem is that upon calling DBCommand.getSelect() call each DBColumn's addSQL() that relies on DBColumn.rowset. That rowset is still LOCATION and NOT LOCATION_2 which causes the alias used in the sql for table LOCATION_2 to be that of LOCATION.

Workarounds:
1. Declare columns in DBTable to be not "final"; This may have other side-effects as the contract to other classes is less strict.
2. Use LOCATION_2.getColumn("ID") in lieu of LOCATION_2.ID. I would imagine this slightly less efficient (because of a loop thru "columns") and also more code to write.

Keep up the good work. Empire-db is really a nice piece of software.

Thanks,

Rom


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (EMPIREDB-82) Cloning does not work if DBTable's column (DBColumn) are declared final (as per shipped examples). Causing table alias in resulting SQL queries to be wrong

Posted by "Francis De Brabandere (JIRA)" <em...@incubator.apache.org>.
     [ https://issues.apache.org/jira/browse/EMPIREDB-82?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Francis De Brabandere updated EMPIREDB-82:
------------------------------------------

    Fix Version/s: empire-db-2.0.7-incubating 

> Cloning does not work if DBTable's column (DBColumn) are declared final (as per shipped examples). Causing table  alias in resulting SQL queries to be wrong
> ------------------------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: EMPIREDB-82
>                 URL: https://issues.apache.org/jira/browse/EMPIREDB-82
>             Project: Empire-DB
>          Issue Type: Bug
>    Affects Versions: empire-db-2.0.6-incubating
>         Environment: Linux +  Glassfish 3.0.3 + JDK 1.6.0_21 + Archlinux
>            Reporter: Romain Gallet
>            Assignee: Rainer Döbele
>             Fix For: empire-db-2.0.7-incubating 
>
>
> Hello,
> For a given application, I needed to join a table LOCATION to itself. The definiftion is:
> @Component("airportsDatabase")
> public class Airports extends DBDatabase {
>     public static class Location extends DBTable {
>         public DBTableColumn ID;
>         [...]
>   
>         public Location(DBDatabase db) {
>             super("location", db);
>             ID = addColumn("ID", DataType.INTEGER, 10, DataMode.NotNull);
>             [...]
>       }
>       public final Location LOCATION = new Location(this);
>       public Airports() {
>     }
> }
> So LOCATION is my primary table object, declared at compile time. At runtime, I clone it like that:
> Airports.Location LOCATION_2 = (Airports.Location) db.LOCATION.clone();
> In org.apache.empire.db.DBTable.clone(), line 119, the Field is used to set the clone's fields set to the new "newCol" (line 108) which itself as a reference to "clone". The problem is that because "ID" (as shown above) is final, the Field.set() triggers an exeption, caught line 120.
> The problem is that upon calling DBCommand.getSelect() call each DBColumn's addSQL() that relies on DBColumn.rowset. That rowset is still LOCATION and NOT LOCATION_2 which causes the alias used in the sql for table LOCATION_2 to be that of LOCATION.
> Workarounds:
> 1. Declare columns in DBTable to be not "final"; This may have other side-effects as the contract to other classes is less strict.
> 2. Use LOCATION_2.getColumn("ID") in lieu of LOCATION_2.ID. I would imagine this slightly less efficient (because of a loop thru "columns") and also more code to write.
> Keep up the good work. Empire-db is really a nice piece of software.
> Thanks,
> Rom

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (EMPIREDB-82) Cloning does not work if DBTable's column (DBColumn) are declared final (as per shipped examples). Causing table alias in resulting SQL queries to be wrong

Posted by "Rainer Döbele (JIRA)" <em...@incubator.apache.org>.
     [ https://issues.apache.org/jira/browse/EMPIREDB-82?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Rainer Döbele resolved EMPIREDB-82.
-----------------------------------

    Resolution: Fixed
      Assignee: Rainer Döbele

This should thave been resolved already togehter with EMPIREDB-60.

> Cloning does not work if DBTable's column (DBColumn) are declared final (as per shipped examples). Causing table  alias in resulting SQL queries to be wrong
> ------------------------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: EMPIREDB-82
>                 URL: https://issues.apache.org/jira/browse/EMPIREDB-82
>             Project: Empire-DB
>          Issue Type: Bug
>    Affects Versions: empire-db-2.0.6-incubating
>         Environment: Linux +  Glassfish 3.0.3 + JDK 1.6.0_21 + Archlinux
>            Reporter: Romain Gallet
>            Assignee: Rainer Döbele
>
> Hello,
> For a given application, I needed to join a table LOCATION to itself. The definiftion is:
> @Component("airportsDatabase")
> public class Airports extends DBDatabase {
>     public static class Location extends DBTable {
>         public DBTableColumn ID;
>         [...]
>   
>         public Location(DBDatabase db) {
>             super("location", db);
>             ID = addColumn("ID", DataType.INTEGER, 10, DataMode.NotNull);
>             [...]
>       }
>       public final Location LOCATION = new Location(this);
>       public Airports() {
>     }
> }
> So LOCATION is my primary table object, declared at compile time. At runtime, I clone it like that:
> Airports.Location LOCATION_2 = (Airports.Location) db.LOCATION.clone();
> In org.apache.empire.db.DBTable.clone(), line 119, the Field is used to set the clone's fields set to the new "newCol" (line 108) which itself as a reference to "clone". The problem is that because "ID" (as shown above) is final, the Field.set() triggers an exeption, caught line 120.
> The problem is that upon calling DBCommand.getSelect() call each DBColumn's addSQL() that relies on DBColumn.rowset. That rowset is still LOCATION and NOT LOCATION_2 which causes the alias used in the sql for table LOCATION_2 to be that of LOCATION.
> Workarounds:
> 1. Declare columns in DBTable to be not "final"; This may have other side-effects as the contract to other classes is less strict.
> 2. Use LOCATION_2.getColumn("ID") in lieu of LOCATION_2.ID. I would imagine this slightly less efficient (because of a loop thru "columns") and also more code to write.
> Keep up the good work. Empire-db is really a nice piece of software.
> Thanks,
> Rom

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.