Quick question on cascade persist

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Quick question on cascade persist

papajdo
Hi,

If I define a cascade persist field in an EntityX and that field is declared to be of type EntityA but at runtime contains a non-Entity subclass of the EntityA, (e.g. NonEntityB extends EntityA), what happens at commit?

I expect that an IllegalArgumentException is thrown because when you try to persist the field, it finds the NonEntityB, which is not an Entity.

The spec seems to indicate that this is an error but apparently some implementations allow NonEntityB to be persisted as if it were an EntityA and when read from the database later, is read as an EntityA.

Yes, I can write a test case but I thought this would be easier (for me).

Thanks,

Craig

smime.p7s (3K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Quick question on cascade persist

Abe White
> If I define a cascade persist field in an EntityX and that field is  
> declared to be of type EntityA but at runtime contains a non-Entity  
> subclass of the EntityA, (e.g. NonEntityB extends EntityA), what  
> happens at commit?

IMO the commit should fail with an appropriate exception.
_______________________________________________________________________
Notice:  This email message, together with any attachments, may contain
information  of  BEA Systems,  Inc.,  its subsidiaries  and  affiliated
entities,  that may be confidential,  proprietary,  copyrighted  and/or
legally privileged, and is intended solely for the use of the individual
or entity named in this message. If you are not the intended recipient,
and have received this message in error, please immediately return this
by email and then delete it.