JBoss conforms to the ejb spec by restricting a single-entity finder
return type to be the EJB entity interface class. If the return type is
not exactly the interface class, then JBoss assumes the result is a
multi-finder and returns an ArrayList. JBoss cannot be expected to relax
the spec, nor should it do so. If anything, JBoss should complain
sooner, raising an exception at deployment.

If the polymorphic find is for internal EB use, consider using a EJB 2.0
CMP select, available with JBoss 3.0. You can fiddle with the select
return type, although I don't know how far that can be carried.

As a rule, if an app is not straight EJB per the spec, then you will you
get burned--if not sooner, then later.

Fred Loney
Spirited Software, Inc.
www.spiritedsw.com

----- Original Message -----
From: "prajapatib" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, October 26, 2001 6:24 AM
Subject: [JBoss-user] polymorphic primary keys


> Hi all,
>
> I have a class that is the super-interface of all primary key classes
> (BasePK). What I have managed to do with this is to implement a
generic
> finder that can go to any entity bean and give back collections of
primary
> keys of the super interface type (in the ebjFindByXXXX() methods).
>
> Over on the way to the home interface side, they are returned as
collections
> of the super-interface type of all remote interfaces.
>
> In simple terms, I have an abstract layer above all my objects and
> interfaces to make queries in all entity beans generic. i.e. you don't
have
> to care what bean you are calling.
>
> This works fine when the signatures of my home and bean findByXXXX
methods
> define the returning of a Collection. But not when it is returning a
single
> row. (It wont let me have a generic findByPK method - JBoss complains
about
> casting from an ArrayList).
>
> My generic finder looks like this:
>
> public Collection ejbFindByAnythingForAnyBean(SomeParameters p)
>
> *this works fine*.
>
> However this doesn't:
>
> public BasePK ejbFindByBasePK(BasePK pk)
> {
>     return pk;
> }
>
> I get a class cast exception----JBoss is trying to return an ArrayList
> (there can only be one object in this ArrayList because I am giving it
a
> primary key to look up by) instead of a single object.
>
> My home interface is fine:
>
> public BaseEJBObject findByBasePK(BasePK pk)
>
> Does anyone know what is going on and why JBoss is refusing to let me
return
> a single primary key from my bean?
>
> Many thanks in advance,
>
> Birju
>
>
>
>
> Disclaimer
>
> This communication together with any attachments transmitted with it
('this E-mail') is intended only for the use of the addressee and may
contain information which is privileged and confidential. If the reader
of this E-mail is not the intended recipient or the employee or agent
responsible for delivering it to the intended recipient you are notified
that any use of this E-mail is prohibited. Addressees should check this
E-mail for viruses. The Carphone Warehouse Group PLC makes no
representations as regards the absence of viruses in this E-mail. If you
have received this E-mail in error please notify our ISe Response Team
immediately by telephone on + 44 (0)20 8896 5828 or via E-mail at
[EMAIL PROTECTED] Please then immediately destroy this E-mail and any
copies of it.
>
> Please feel free to visit our website: http://www.phonehouse.com
>
>
> _______________________________________________
> JBoss-user mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/jboss-user
>


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

Reply via email to