empire-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rainer Döbele (JIRA) <empire-db-...@incubator.apache.org>
Subject [jira] [Closed] (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
Date Mon, 04 Feb 2013 14:12:15 GMT

     [ https://issues.apache.org/jira/browse/EMPIREDB-82?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

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


Cleanup of unclosed issues.
                
> 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.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message