On Tue, 30 Mar 2004, Gary wrote:

> I am wondering why the methods getFieldRecursive() and
> getNestedFieldRecursive() in class
> AbstractPersistentField are private.  I would like to
> have the ability to override them in a custom
> persistent field implementation.
> 
> Here is my dilemma:
> 
> I have the following classes:
> 
> package ojb;
> 
> public interface IParent {
>       IChild getChild();
>       void setChild(IChild child);
> }
> 
> package ojb;
> 
> public interface IChild {
>       String getDescription();
>       void setDescription(String description);
> }
> 
> package ojb;
> 
> public class Parent implements IParent {
>       private IChild child = null;
>       
>       public Parent() {
>               super();
>       }
> 
>       public IChild getChild() {
>               return child;
>       }
> 
>       public void setChild(IChild child) {
>               this.child = child;
>       }
> 
> }
> 
> package ojb;
> 
> public class Child implements IChild {
>       private String description = null;
>       
>       public Child() {
>               super();
>       }
> 
>       public String getDescription() {
>               return description;
>       }
> 
>       public void setDescription(String string) {
>               description = string;
>       }
> 
> }
> 
> 
> 
> I have the following OJB metadata.
> <field-descriptor
> name="child::description"
>       column="childDescription"
>       jdbc-type="VARCHAR"
> />
>   
> I am using a subclass of
> PersistentFieldIntrospectorImpl.  The problem is that
> when it tries to resolve “child::description,” it ends
> up going through the “IChild getChild()” method
> signature.  This causes it to analyze the fields of
> IChild; of course there aren’t any, so it fails with a
> MetadataException.
> 
> If I could override methods getFieldRecursive() and
> getNestedFieldRecursive(), I could substitute at run
> time a class that implements IChild.
> 
> Any ideas?  I really need to return a reference to an
> interface here, rather than to a concrete class, as
> our design is heavily interface based.

Have you tried the CVS version ? I made some changed that may be of
interest to you:

* methods getFieldRecursive and getNestedRecursiveField are static and,
though still private, you can use them via the protected static method
computeField in AbstractPersistentField

* I fixed getFieldRecursive such that it no longer throws an exception
when given an interface

* support for interfaces in the repository descriptor is now much
better; specifically using PersistentFieldIntrospectorImpl
(bean-access) or PersistentFieldAutoProxyImpl (detects access method
automatically - best for mixing concrete classes and interfaces) should
work much better now

Perhaps you could try the CVS version with the unmodified
PersistentFieldIntrospectorImpl, and if you still have problems, then
please post the stacktrace ?

Tom


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

Reply via email to