-->
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.  [ 1 post ] 
Author Message
 Post subject: Sub-Subclass Discrimnator Columns
PostPosted: Thu Oct 13, 2005 2:36 pm 
Beginner
Beginner

Joined: Wed Nov 05, 2003 4:38 pm
Posts: 29
Will it ever be possible to have sub-subclasses with a different discriminator column from their parent class? If not is there a way to map this without them?

For example I have a legacy table that stores information like this (and it can't be changed):

company_group = 'C', 'I', 'B'
tier_type = '0', '1', '2', '3', '4', '5', '6'

Company = ??, ?? (abstract base class)
BillingCompany = B, 0 (extends Company)
InsuranceCompany = I, 0 (extends Company)
TierCompany = C, ?? (abstract base class extends Company)
Tier1Company = C, 1 (extends TierCompany)
Tier2Company = C, 2 (extends TierCompany)
Tier3Company = C, 3 (extends TierCompany)
Tier4Company = C, 4 (extends TierCompany)
Tier5Company = C, 5 (extends TierCompany)
Tier6Company = C, 6 (extends TierCompany)

Technically the tier companies do not have to be split out but it does help to have them split this way since I can attach methods to the separate classes that help to work with the 6 level hierarchy that the tier columns represent.

The table is laid out as follows:

Company Table:
[code]
company_id
company_name
company_group
tier_type
address1
address2
city
state
zip_code
tier1_name // Only found in tier 1 companies
tier2_name // Only found in tier 1 companies
tier3_name // Only found in tier 1 companies
tier4_name // Only found in tier 1 companies
tier5_name // Only found in tier 1 companies
tier6_name // Only found in tier 1 companies
tier1_company_id // All of these below are only found in tier companies
tier2_company_id
tier3_company_id
tier4_company_id
tier5_company_id
tier5_company_id
[/code]

An example of the mapping I'm talking about would look like this:

[code]
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="Company" table="company" discriminator-value="">
<id column="company_id" name="companyId" type="string">
<generator class="assigned"/>
</id>
<discriminator column="company_group" type="string"/>
<property name="companyGroup" column="company_group" type="string" insert="false" update="false"/>
<property name="tierType" column="tier_type" type="string" insert="false" update="false"/>
<property name="name" column="company_name" type="string"/>
<component name="address" class="Address">
<property name="line1" column="address1" type="string"/>
<property name="line2" column="address2" type="string"/>
<property name="city" column="city" type="string"/>
<property name="state" column="state" type="AddressStateType"/>
<property name="zipCode" column="zip_code" type="string"/>
</component>
<subclass name="BillingCompany" discriminator-value="B">
</subclass>
<subclass name="InsuranceCompany" discriminator-value="I">
</subclass>
<subclass name="TierCompany" discriminator-value="C">
<discriminator column="tier_type">
<many-to-one name="tier1Company" column="tier1_company_id"/>
<many-to-one name="tier2Company" column="tier2_company_id"/>
<many-to-one name="tier3Company" column="tier3_company_id"/>
<many-to-one name="tier4Company" column="tier4_company_id"/>
<many-to-one name="tier5Company" column="tier5_company_id"/>
<many-to-one name="tier6Company" column="tier6_company_id"/>
<subclass name="Tier1Company" discriminator-value="1">
<property name="tier1Name" column="tier1_name" type="string"/>
<property name="tier2Name" column="tier2_name" type="string"/>
<property name="tier3Name" column="tier3_name" type="string"/>
<property name="tier4Name" column="tier4_name" type="string"/>
<property name="tier5Name" column="tier5_name" type="string"/>
<property name="tier6Name" column="tier6_name" type="string"/>
</subclass>
<subclass name="Tier2Company" discriminator-value="2">
</subclass>
<subclass name="Tier3Company" discriminator-value="3">
</subclass>
<subclass name="Tier4Company" discriminator-value="4">
</subclass>
<subclass name="Tier5Company" discriminator-value="5">
</subclass>
<subclass name="Tier6Company" discriminator-value="6">
</subclass>
</subclass>
</class>
</hibernate-mapping>
[/code]


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

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.