Thanks for the response Chris - it helped set me off looking at the right area to get it working.

For the benefit of others here is a result of my findings.

1. Because the foreign keys were not defined in the AGENT alias at all the generated BaseAgentPeer had numColumns set to 1, so that even though I'd defined the extra columns in TurbineUserAdaptor, although the correct SQL was being generated to get the information from the turbine user table they weren't being put into Perm correctly (that's my theory based on my limited knowledge). Once i changed the definition of AGENT in my xml schema as follows:
<column name="EO_ID" required="true" type="INTEGER"/>
<column name="ST_ID" required="true" type="INTEGER"/>
<foreign-key foreignTable="ORGANISATION">
<reference local="EO_ID" foreign="O_ID"/>
</foreign-key>
<foreign-key foreignTable="STATUS">
<reference local="ST_ID" foreign="ST_ID"/>
</foreign-key>

then BaseAgentPeer had the correct number of columns , and I could then retrieve the foreign key (eventually - see next comment:-))

2. The docs describing the creation of TurbineUserAdapter and TurbineUserPeerAdapter are not precise enough for when you want to set up something other than a straightforward column (or perhaps my reading is not deep enough - who knows). I had made a few errors here which I had to rectify before I could get it completely working.

2.1 Foreign Keys are not string values they are NumberKey values so when defining setter/getter must match accordingly.
2.2 I had a string constant referring to STATUS rather than the actual column name of ST_ID - perhaps my not quite understanding that there is a strict 1:1 with the table column names, and that getter and setter methods must follow the naming convention i.e for ST_ID it is getStId
2.3 had to reflect the changed method names introduced in TurbineUserAdaptor in TurbineUserPeerAdaptor.
2.4 Also had TurbineMapBuilderAdapter defined as a private in TurbineUserPeerAdapter - had to change to public.

3. TurbineMapBuilderAdapter
3.1 Changed method names to reflect thos in TurbineUserAdapter
3.2 Realised that the object being created had to represent the type of the columns they were going to be used with ie for a Foreign Key needed to use a NumberKey object.
3.3 Realised that for foreign keys that addForeignKey method is used instead of addColumn method for adding the foreign key columns to the map.

It may well be that this is all obvious if I'd looked properly - but I couldn't see it easily. At least I'll be able to get an early night tonight :-))

Malcolm

At 09:30 18/11/02 -0700, you wrote:

Hi Malcolm.

Gosh, you are really doing a lot of extending, and the problem could be just
about anywhere.  I would suggest setting up some junit test cases and adding
the extensions one-by-one, that is, adding a new extension only after the
previous extension passes the test.  When you get to specific problem that
you can't figure out, we will be much more likely to lead you in the right
direction.

Also, it is a good practice to write Services to wrap your OM layer instead
of repeatedly using the Peers.  In this case, Turbine already provides a
service, the TurbineSecurity Service:

TurbineUserAdapter user =
(TurbineUserAdapter)TurbineSecurity.get("username");
assertEquals("Name","name",user.getFirstName());
assertEquals("EoId","1",user.getEoId());

Good luck,

Chris

> -----Original Message-----
> From: malcolm cooke [mailto:[EMAIL PROTECTED]]
> Sent: Monday, November 18, 2002 5:05 AM
> To: Turbine Users List
> Subject: Problems extending user as per how to (and previous messages)
>
>
> Hi,
> I am Using tdk 2.1.and trying to extend turbine_user as per the
> how to and
> have made patches to Object.vm as described in previous threads on this
> subject. I am a newbie as far as turbine is concerned and any
> help would be
> appreciated.
>
> I have extended turbine user as per the how to  i.e
>       <table name="TURBINE_USER" idMethod="idbroker">
>               <column name="USER_ID" required="true"
> primaryKey="true" type="INTEGER"/>
>               <column name="EO_ID" required="true" type="INTEGER"/>
>               <column name="ST_ID" required="true" type="INTEGER"/>
>               <column name="LOGIN_NAME" required="true" size="32"
> type="VARCHAR"/>
>               <column name="PASSWORD_VALUE" required="true"
> size="32" type="VARCHAR"/>
>               <column name="FIRST_NAME" required="true" size="99"
> type="VARCHAR"/>
>               <column name="LAST_NAME" required="true" size="99"
> type="VARCHAR"/>
>               <column name="EMAIL" size="99" type="VARCHAR"/>
>               <column name="CONFIRM_VALUE" size="99" type="VARCHAR"/>
>               <column name="MODIFIED" type="TIMESTAMP"/>
>               <column name="CREATED" type="TIMESTAMP"/>
>               <column name="LAST_LOGIN" type="TIMESTAMP"/>
>               <column name="NOTES" size="255" type="VARCHAR"/>
>               <column name="OBJECTDATA" type="VARBINARY"/>
>               <unique>
>                       <unique-column name="LOGIN_NAME"/>
>               </unique>
>               <foreign-key foreignTable="ORGANISATION">
>                       <reference local="EO_ID" foreign="O_ID"/>
>               </foreign-key>
>               <foreign-key foreignTable="STATUS">
>                       <reference local="ST_ID" foreign="ST_ID"/>
>               </foreign-key>
>       </table>
>
> with amongst other things two foreign keys. My Agent table
> definition is as
> follows:
>       <table name="AGENT" javaName="Agent" alias="TurbineUser"
> baseClass="com.testthingy.test.om.TurbineUserAdapter"
> basePeer="com.testthingy.test.om.TurbineUserPeerAdapter">
>               <column name="USER_ID" primaryKey="true"
> autoIncrement="true"
> required="true" type="INTEGER"/>
>       </table>
>
> I have created the TurbineUserAdapter with the following methods :
>
>   public void setEoId(NumberKey org)    {
>          setPerm(EO_ID, org);
>      }
>
>      public NumberKey getEoId()    {
>          NumberKey tmp = null;
>          try   {
>              tmp = (NumberKey) getPerm(EO_ID);
>          }
>          catch ( Exception e )
>          {
>          }
>          return tmp;
>      }
>
> and TurbineUserAdapterPeer with
>      public static final String EO_ID = mapBuilder.getUser_EoId(); in it.
>
> TurbineMapBuilderAdapter has the following:
>
>       public static String getEoId()    {
>          return "EO_ID";
>      }
>
>      public String getUser_EoId()    {
>          return getTableUser() + '.' + getEoId();
>      }
>
>
> THE PROBLEM:
> When I try to access the EO_ID column via the agent i.e
>       NumberKey numkey = new NumberKey("0");
>
>          tester = AgentPeer.retrieveByPK(numkey);
>          System.out.println("pk = " + tester.getUserId());
>          System.out.println("name = " + tester.getFirstName());
>          System.out.println("eoid = " + tester.getEoId());
>
> I get the User Id and the First name correctly , but it always
> returns null
> for getEoId(). Where am I going wrong?
>
> thanks
>
> Malcolm
>


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>




---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.417 / Virus Database: 233 - Release Date: 08/11/02
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.417 / Virus Database: 233 - Release Date: 08/11/02

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to