[Opensource] Using OtherDBObject in Expresso 5.0

Devos, Edward Edward.Devos at GPSupport.com
Fri Oct 18 01:15:58 PDT 2002


Hi All,

Thanks for the swift reply, but I'm facing the following problem.

I have an "engineer" table in the "webtrack" context and a corresponding
DBObject 
(class engineer extends SecuredDBObject), in this DBObject I have virtual
fields that reference data that is stored in the "default" context (where
the expresso tables live) by means of setMultiValued() and setLookupObject()

Keep in mind that the "webtrack" context has
"<hasSetupTables>false</hasSetupTables>", so all non application tables
(expresso tables thus) are to be found in the "default" context, and that
all "webtrack" DBObjects are added in the schema as follows :

<SNIP>
	
addDBObject(org.omini.expresso.webtrack.dbobj.Engineer.class.getName(),
"webtrack");
</SNIP>

so when I override the getField(), I include the following code :

<SNIP>
        if (fieldName.equals("FIRSTNAME") )
        {
            RegisteredUser regUser = new RegisteredUser();
            regUser.setDataContext(); // defaults to the "default" context
            regUser.setField("ExpUid", this.getField("ID"));
            if ( regUser.find())
            {
                regUser.retrieve();
                //System.out.println("engineer:getField(\"Firstname\")
:"+getField("FIRSTNAME"));
                return regUser.getField("FirstName");
            }
            return "No Engineer FirstName Found";
        }
        else if (fieldName.equals("EMAIL") )
        {
            DefaultUserInfo oneUser = new DefaultUserInfo();
            oneUser.setDataContext(); //defaults to the "default" context
            oneUser.setUid(this.getFieldInt("ID"));
            
            if ( oneUser.find() )
            {
                oneUser.retrieve();
                if ( oneUser.getEmail().length() > 0 )
                {
                    System.out.println("oneUser.getEmail()
:"+oneUser.getEmail());
                    return oneUser.getEmail();
                }
            }
            return "No Engineer Email Found";
        }
</SNIP>	  

The problem is that when I do this, expresso is looking for the
DefaultUserInfo ( USERSTABLE ) table in the "webtrack" context instead of in
the "default" context, no matter what I set as "DataContext"

Best regards,

Edward Devos

GPSupport NV
Ajuinlei 1
9000 Gent
+32 (0)9 269 52 52
edward.devos at gpsupport.com




""Javier Campoamor"" <jcampoamor at lapize.com> wrote in message
news:<008401c2761f$2602b2d0$12001aac at Delgado>...
Hi,

When you associate an DBObject to a database (context), it doesn't
matter if you specify another context, even the default context, the
DBObject always tries to search the associated context.

If you want to use the same DBObject in different contexts, you
shouldn't associate it with a context in the Schema. Later, when you use
the DBObject, you can specify the context dynamically.

// Marca will be linked to the TELCOMUNITY context (there will be an
entry in the DBOtherMaps table for this)
	addDBObject( "com.lapize.telcomunity.dbobj.Marca", "TELCOMUNITY"
);
// Telefono won't be linked to any specific database.
	addDBObject( "com.lapize.telcomunity.dbobj.Telefono" );


Regards

Javier


 -----Mensaje original-----
De: opensource-admin at jcorporate.com
[mailto:opensource-admin at jcorporate.com] En nombre de Devos, Edward
Enviado el: jueves, 17 de octubre de 2002 15:43
Para: 'opensource at jcorporate.com'
Asunto: [Opensource] Using OtherDBObject in Expresso 5.0


Hi All, 
I'm testing the otherDBObject method to have two seperate databases, one
for expresso tables, and one for the applications own tables. but Im
running into the following problem now:
I'm logged in as Administrator in the default context! 


More information about the Opensource mailing list