empire-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rainer Döbele <doeb...@esteam.de>
Subject re: how to add a "foreign" table
Date Fri, 12 Feb 2010 20:17:02 GMT
Hi Eike,

first I want to thank you very much for your submission of the spring example.
Unfortunately I did not have the chance to look at it so far - but I am quite keen to do so.
I'll let you know when I have.

Now about your question:
A DBTable object may only belong to one database object just like an XMLElement belongs to
its XMLDocument.
This assignment is usually performed on creation of the DBTable and there is no mechanism
to change it.

Hence if you really need to need a copy of the table object of one database in another one
you need to create a new instance of the table object.
Normally you would just create a instalce of the table like this:

    DBTable t = new DB1.SomeTable(db2);

If your code should be more generic then you might use something like:

    DBTable t = db1.getTable(...);
    t.getClass().getConstructor(DBDatabase.class).newInstance(new Object[] { db2 });

This assumes that the table has a constructor that takes the db as a parameter.

Hope this is what you need.
Otherwiese I would need to know what excatly you are trying to achieve with this.

Regards
Rainer


Eike Kettner wrote:
> re: how to add a "foreign" table
> 
> Hello all,
> 
> I'm facing a problem that I want to add a table from one db to another
> db. I have two DBDatabases and I like to add a table from DB1 to DB2,
> something like this:
> 
> 
>   DBDatabase db1 = ..
>   DBDatabase db2 = ..
> 
>   DBTable table1 = db1.getTable(0);
> 
>   db2.addTable(table1);
> 
> 
> actually, what i want is to create a table on DB2 that is present on
> DB1, without too much coding ;-)
> 
> Thankful for any help!
> 
> Kind regards,
> Eike

Mime
View raw message