users@glassfish.java.net

Re: Can't map DiscriminatorColumn as attribute of parent class

From: <glassfish_at_javadesktop.org>
Date: Mon, 25 Jun 2007 07:56:50 PDT

I'm not sure why you would have the discriminator column mapped - if its an instance of A its one value, if its an instance of B its something else. If the provider did allow it to be mapped, then it opens the potential that it can be changed - for instance having a class B, and changing the discriminator column's mapping to be of class C would really mess things up. When it goes to persist the object, does it persist it as a B or C object? TopLink Essentials throws an exception when it determins there are multiple writable mappings for the same field to avoid these situations.

One solution is to mark the column mapping as insertable=false, updatable=false Another could be to mark it as @Transient so its never persisted but initialize it in the constructor - since A's source value will always be "A" and B's will always be "B" etc.

Best Regards,
Chris
[Message sent by forum member 'chris_delahunt' (chris_delahunt)]

http://forums.java.net/jive/thread.jspa?messageID=223787