persistence@glassfish.java.net

Re: How to use discriminator type with integer?

From: Marina Vatkina <Marina.Vatkina_at_Sun.COM>
Date: Tue, 05 Sep 2006 13:07:32 -0700

hi Sherry,

Looks like a bug to me. Does it work in non-java2db case
if you use DiscriminatorType.INTEGER and column type numeric?

thanks,
-marina

Sherry Shen wrote:
>
>
> In my test, the discriminator type is INTEGER.
>
> 1) The discriminator in DDL file by Java2DB is VARCHAR.
> Does this work by design?
>
> 2) When the discriminator value is given as "ABC",
> there is no exception.
> Is this correct?
>
> 3) In Spec 9.1.31, Discriminator Value Annotation,
> "If the discriminator type is an integer, the value specified
> must be able to converted to an integer value (e.g., "1")."
> Does it refer to the usage of @DiscriminatorValue("1") ?
>
> Thanks for the help!
>
> Sherry
>
> PS: my test
> @Entity
> @Inheritance(strategy=InheritanceType.JOINED)
> @DiscriminatorColumn(name="DCOL",
> discriminatorType=DiscriminatorType.INTEGER)
> public class BaseInfo implements java.io.Serializable {
>
> @Entity
> *_at_DiscriminatorValue("ABC")*
> public class ClientInfo extends BaseInfo {
>
> % more createDDL.jdbc
> CREATE TABLE BASEINFO (ID VARCHAR(255) NOT NULL,
> DCOL VARCHAR(31), NAME VARCHAR(255), PRIMARY KEY (ID))
> CREATE TABLE CLIENTINFO (ID VARCHAR(255) NOT NULL,
> PROP2 VARCHAR(255), PRIMARY KEY (ID))
> ALTER TABLE CLIENTINFO ADD CONSTRAINT FK_CLIENTINFO_ID
> FOREIGN KEY (ID) REFERENCES BASEINFO (ID)
> %
>
> [TopLink Fine]: 2006.09.05 09:08:42.334--ClientSession(33492446)
> --Connection(32603767)--Thread(Thread[main,5,main])
> --INSERT INTO BASEINFO (ID, NAME, DCOL) VALUES (?, ?, ?)
> bind => [foo, Sherry, ABC]
> [TopLink Fine]: 2006.09.05 09:08:42.423--ClientSession(33492446)
> --Connection(32603767)--Thread(Thread[main,5,main])
> --INSERT INTO CLIENTINFO (PROP2, ID) VALUES (?, ?)
> bind => [myP2, foo]