> You can then simply hard code the category id in the ejbql
> for each method in your descriptors
But I can't do that because if I have 2 different types of products
(say Books and Magazines) but they're both in the category "Print
Items," then I need to return two different Entity types. I know this
can be done in EJB 3.0, but how would I do it in 2.0?
Both entities will be stored in diff. tables from each other in the DB.
Obviously, I could do it in BMP, but I'd like to do it in CMP. Is there
a way to do it?
Big Jim - 07 May 2005 22:46 GMT
>> You can then simply hard code the category id in the ejbql
>> for each method in your descriptors
[quoted text clipped - 7 lines]
> Obviously, I could do it in BMP, but I'd like to do it in CMP. Is there
> a way to do it?
You could return a collection of print items in your printItems home, e.g.
with a query using "where categoryId IN(bookId, magazineId)". You would be
able to cast each item in the collection to printItem but not to book or
magazine.
I thnk the only way you can make this work sensibly is if your inheritance
tree follows you categorization i.e. you have books and magazines extending
printItems thus allowing you to group these items together.
If they are in separate tables i.e. not differentiated by an id column in
the same table, then they are different types of object and presumably have
different attribues/behaviour and I'm not then sure why you'd want to get
them by a category id, maybe you could look at your design and find a better
way to do this e.g. jst amalgamate the collections of each type in a wrapper
method to work with them from there.
You can have abstract schemas defined in your descriptor for a cmp bean that
extend over many tables but how this is done may well depend on your j2ee
server.