db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thomas Fischer <tfisc...@apache.org>
Subject Re: Dynamic table name
Date Sun, 19 Jun 2005 12:31:47 GMT
Hi Paul,

probably this can only be done within Torque if you change the internal 
proceedings a bit.
Torque keeps the information about the database layout in a map called 
databaseMap. It can be accessed via Torque.getDatabaseMap(). You have to 
make sure thsi returns the right information. Probably you have to change 
this method and recompile Torque to do that.
Then, there is the constant DATABASE_NAME in the generated peer, and the 
method getMapBuilder() in the generated peer. I do not know if you need to 
change these for querying.

Perhaps it is better to create a criteria using a fixed table with the 
same structure, get the query, parse it and replace the table name, and 
get the Peer to fill the results from the query. But then I have no idea 
how the single steps could be achieved.

I am afraid I know no easy way to do it in Torque. Perhaps it is easier to 
do it in the database. Some mad idea would be
- before querying the table, cerate a view with the same name
- query the view via its peer class
- remove the view.
I am afraid this will not work for concurrent users, but maybe there is a 
better way (Trigger? stored procedure ? I have no experience with these 
things)

     Thomas

On Fri, 17 Jun 2005, Husek, Paul wrote:

> Hello,
>
>
>
>
>
> I need to query a table who's structure is constant but who's name changes
> depending on the date and time of day (e.g. Dynamic_06171120 or
> Dynamic_06171450).  I've defined a table in Torque schema with the proper
> layout but I'm wondering how I can dynamically change the table name of this
> base class so it queries the proper table.  I'm thinking about something
> like:
>
>
>
> Criteria c=new Criteria();
>
> c.setTableName("Dynamic_06171450");
>
> c.add(DynamicPeer,ID ,10);
>
> List l=DyanmicPeer.doSelect( c );
>
>
>
> Can anything like this be done?
>
>
>
> Thanks!
>
>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org


Mime
View raw message