-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Regarding using subclass with discriminator
PostPosted: Thu Jun 09, 2005 10:39 am 
Newbie

Joined: Wed May 25, 2005 10:53 pm
Posts: 13
Hi.

I have the foll. scenario:

Table PAYMENT has been mapped using Table per subclass, using a discriminator with column "CARD_TYPE" of table PAYMENT as the discriminator column.
I want to know whether I can use the same Java class for different values of discriminator???, i.e, can I have such a mapping:

<class name="Payment" table="PAYMENT">
<id name="id" type="long" column="PAYMENT_ID">
<generator class="native"/>
</id>
<discriminator column="CARD_TYPE" type="string"/>
<property name="amount" column="AMOUNT"/>
...

<subclass name="CreditCardPayment" discriminator-value="VISACARD">
...........</subclass>

<subclass name="CreditCardPayment" discriminator-value="MASTERCARD">
...........</subclass>

......
</class>

The subclass is same for different values of the discrminator field. Is this possible??

Thanks in advance,
Rakesh S


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 09, 2005 10:55 am 
Regular
Regular

Joined: Thu May 26, 2005 2:08 pm
Posts: 99
I haven't done this personally, but 24.4.3 might be helpful if you try mapping multiple values of CARD_TYPE to a single discriminator value.


Code:
    <discriminator
        type="character">
        <formula>
            case
                when title is not null then 'E'
                when salesperson is not null then 'C'
                else 'P'
            end
        </formula>
    </discriminator>


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.