Hi,

I've been working with Turbine for a couple of weeks, on and off, and
am finally getting to the point where I would need to do some joins
between some tables to build some output for the users.

I'm using Torque to generate the om classes, and for example, my db
looks something like this:

TABLE A
   A_ID INTEGER
   B_ID INTEGER
   SCORE INTEGER

TABLE B
   B_ID INTEGER
   C_ID INTEGER
   NAME VARCHAR

TABLE C
   C_ID INTEGER
   NAME VARCHAR

The foriegn keys are declared and matched up in my torque definition.

So each of these tables is represented by a peer object, and I'm trying
to do something like

SELECT A.SCORE, B.NAME, C.NAME FROM A, B, C WHERE A.B_ID = B.B_ID AND
  B.C_ID = C.C_ID;

My question is, what is the preferred method to fit this into the peer
model?  Do I create some new peer objects that have these columns
defined?  When I do a select now, using one of the existing peer
objects, say A's, I end up with a DataSetException.  My criteria creation
is like this:

Criteria ct = new Criteria();
ct.addSelectColumn(APeer.SCORE);
ct.addSelectColumn(BPeer.NAME);
ct.addSelectColumn(CPeer.NAME);
ct.addJoin(APeer.B_ID, BPeer.B_ID);
ct.addJoin(BPeer.C_ID, CPeer.C_ID);
ct.addOrderByColumn(APeer.SCORE);

My understanding from the docs (which I have read, but can't find
an example of a join) is that what will return from an 

APeer.doSelect(ct);

will be a vector of rows for the results, cast as the data object,
which knows nothing of these other tables (I assume the
DataSetException is from when it's trying to cast one of the
NAME strings into the INTEGER SCORE column in A).

Should I create a class that has the correct columns, and then call
APeer.doSelect(), specifying this new class as the class to cast to
(thought I notice in the source that this will use row2Object, which
assumes that the peer's real data object is being used).  Or do I
need to create a new peer altogether?  Or is there a cleaner solution
I'm totally missing?

Sorry for this being so long-winded...any pointers (even RTFM)
or suggestions appreciated.

Thanks



------------------------------------------------------------
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
Search: <http://www.mail-archive.com/turbine%40list.working-dogs.com/>
Problems?:           [EMAIL PROTECTED]

Reply via email to