Let's asume the Employee remote interface inherits from (interface) Person.
Let's also asume the Employee home interface inherits from PersonHome (Where
person is not a bean itself!) and PersonHome has a finder-method which
returns a object of type person.
(I tried to implement this.)
Then the container is not able to cast the interface as assumed. I would
expect an instance of Employee which is casted to Person. But the container
throws runtime exceptions. The EJB specification is not clear at this point.
Inheritance between EJB's is not specified, but inherit home and remote
interfaces is allowed. (EJB 1.1 spec appedix B.2)

Now I use a workaround:

If I have Employee und Customer EB which are logical Persons, I define a
finder-method in each home interface an use reflection to envoke the
finder-method on the interface. So I dont need to know with wich EB I work
really.

        Object parentHome = initial.lookup(name evaluated at runtime i.e
EmployeeEntity);
        Class thisRemote = Class.forName(name evaluated at runtime too i.e
Employee);
        java.lang.reflect.Method finder =
thisRemote.getMethod("findByPrimaryKey", new Class[]
{java.lang.String.class} ); 
                                
        Person thisPerson = (Person)finder.invoke(parentHome, new Object[]
{new String(parentId)} );
        this.sel = thisPerson.getSelection(childName); //some method from
interface Person

 
> -----Original Message-----
> From: Nordahl, David C [SMTP:[EMAIL PROTECTED]]
> Sent: 19 April 2001 17:28
> To:   '[EMAIL PROTECTED]'
> Subject:      [JBoss-user] Finder method question
> 
> I'm wondering if it is possible to create a finder method for an attribute
> which is nested in another object attribute of my bean.  For example, say
> I
> have an Employee bean with an attribute of type Person (non bean) which
> has
> an attribute of last and first name, and I want to make a method
> findByFirstName.  Is this possible? And if so how is it done? 
> 
> _______________________________________________
> JBoss-user mailing list
> [EMAIL PROTECTED]
> http://lists.sourceforge.net/lists/listinfo/jboss-user

_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to