cayenne-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Gentry <>
Subject Bug in inheritance + callbacks?
Date Tue, 30 Mar 2010 15:52:53 GMT
OK, this is kind of a followup on the generated abstract class...

I'm attempting to test using inheritance with an enum as the
discriminator column and a callback.  For my classes:

Product (Abstract) with Book and Game inheriting from Product.

Product contains an enum (ProductType) to discriminate between the two.

Product's post-add callback I set to "initializeProductType" and
Cayenne generated this in

    protected abstract void initializeProductType();

I had to go into and change that class to be abstract (I
don't want any instances of it created).  I implemented
initializeProductType() in and (my only subclasses
thus far).  At runtime, I get this exception:

Exception in thread "main" java.lang.IllegalArgumentException: Class
mrg.model.Product has no valid callback method 'initializeProductType'

Of course, this exception message is entirely true: Product does not
contain initializeProductType() because it is in the subclasses.

Thoughts on if this is legitimate?



PS. The callback method implementation is: @Override protected void
initializeProductType() { setProductType(ProductType.BOOK); } (for
Book, of course).

View raw message