Return-Path: Mailing-List: contact turbine-torque-user-help@jakarta.apache.org; run by ezmlm Delivered-To: mailing list turbine-torque-user@jakarta.apache.org Received: (qmail 5423 invoked by uid 98); 17 Dec 2002 00:13:59 -0000 X-Antivirus: nagoya (v4218 created Aug 14 2002) Received: (qmail 5384 invoked from network); 17 Dec 2002 00:13:56 -0000 Received: from daedalus.apache.org (HELO apache.org) (63.251.56.142) by nagoya.betaversion.org with SMTP; 17 Dec 2002 00:13:56 -0000 Received: (qmail 4110 invoked by uid 500); 17 Dec 2002 00:12:40 -0000 Received: (qmail 4092 invoked from network); 17 Dec 2002 00:12:40 -0000 Received: from www.honors.tntech.edu (HELO honors.tntech.edu) (149.149.47.115) by daedalus.apache.org with SMTP; 17 Dec 2002 00:12:40 -0000 Received: from localhost (will@localhost) by honors.tntech.edu (8.11.6/8.11.6) with ESMTP id gBH0LKO18872 for ; Mon, 16 Dec 2002 18:21:20 -0600 Date: Mon, 16 Dec 2002 18:21:20 -0600 (CST) From: Will Holcomb To: Turbine Torque Users List Subject: buildCriteria inheritance problem Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N I thought that I sent this the other day, but it appears to have disappeared. =) I have three programs that all use the Turbine user management system. One of them is a web board program. In it the user peer class looks like this: java.lang.Object | +--org.apache.torque.util.BasePeer | +--org.apache.turbine.om.security.peer.TurbineUserPeer | +--org.himinbi.turbine.util.TurbineUserPeerAdapter | +--org.himinbi.directory.om.BaseDirectoryUserPeer | +--org.himinbi.directory.om.DirectoryUserPeer The issue at hand is that BaseDirectoryUserPeer makes a call to static void buildCriteria(ObjectKey). There is no such method in TurbineUser, so it fails. I would just define it in TurbineUserPeerAdapter except the implementation needs to look like: public static Criteria buildCriteria( ObjectKey pk ) { return new Criteria().add(USER_ID, pk); } USER_ID is a static field defined in BaseDirectoryUserPeer and so getting access to it in the superclass is difficult. Actually I can't come up with a way at all. Options I have considered: 1. abstract String getIdColumnName(). Problem is that I can't access an abstract method from within a static context. I thought perhaps I could create a static instance and then call the abstract method on that instance, but there is no way to find out the subclass name from within a static context to the best of my knowledge. 2. reflection. getClass() cannot be called from in a static context. This is the reason creating an instance isn't possible using reflection. 3. special constructor. I don't control the code in the BaseDirectoryUserPeer and it can be overwritten by the build process, so I could do this, but it will break if I ever change the schema and regenerate the Base* classes. Options that don't actually get access in the superclass, but will work are: 1. Having the DirectoryUserPeer initialize the TurbineUserPeerAdapter using a static initializer. 2. Defining a separate adapter for each project that accesses the Turbine user management system. Each adapter can then make specific access to the static fields in the subclasses. Both of these though require redundant code every time I use the adapter. Does anyone know a way for me to avoid that? Will