[hibernate-issues] [Hibernate-JIRA] Created: (HHH-2518) Inheritance Mapping with not distinct composite-key over all tables

Rainer Buhl (JIRA) noreply at atlassian.com
Sat Mar 24 09:43:52 EDT 2007


Inheritance Mapping with not distinct composite-key over all tables
-------------------------------------------------------------------

                 Key: HHH-2518
                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2518
             Project: Hibernate3
          Issue Type: Bug
          Components: core
    Affects Versions: 3.2.1
         Environment: XP
            Reporter: Rainer Buhl


table 1: conversionRuleMT
table 2: conversionRuleQCS
fields: client_id, subscriber_id, input_value, output_value
composite-key: client_id + subscriber_id + input_value
entries (two entries in different table with the same key: 1, 1, A):
conversionRuleMT
1, 1, A, MT1
2, 1, 3, MT3
conversionRuleQCS
1, 1, A, QCS1
3, 1, K, QCS4

abstract class: ConversionRule
concrete classes: ConversionRuleMT, ConversionRuleQCS

mapping

	<class name="ConversionRule" abstract="true">
		<composite-id>
			<key-property name="clientId" column="client_id"></key-property>
			<key-property name="subscriberId" column="subscriber_id"></key-property>	
			<key-property name="inputValue" type="string" column="input_value" />
		</composite-id>
		<property name="outputValue" type="string" column="output_value"/>
		<property name="description" column="DESCRIPTION" />			
		<property name="isDefault" column="IS_DEFAULT" />			
		<union-subclass name="ConversionRuleMT" table="subscribing_client_MT"></union-subclass>
		<union-subclass name="ConversionRuleQCS" table="SUBSCRIBING_CLIENT_QCS">
                                           </unionsubclass>	
	</class>

from hibernate created objects contained in one collection:

- objects from type conversionRuleMT:
"1, 1, A, MT1"
"2, 1, 3, MT3"
"1, 1, A, QCS1" => Error,wrong class, because another table!, 
but same key (1,1,A) as objec1 1 from class conversionRuleMT. Must be from type conversionRuleQCS!

- objects from type conversionRuleQCS
"3, 1, K, QCS4"

Hibernate does not distinguishe the different class of two entries from different tables which 
have the same composite-id. The first object of table conversionRuleMT ("1, 1, A, MT1") in the collection
defines from which type is the next item from another table, because both entries have the same key.
The same key (1, 1, A) has higher priority than the different table from where the next 
object comes "1, 1, A, QCS1" (conversionRuleQCS). And hibernate does create a new object nor it has the same "identity",
but from a wrong type.

Is this a bug, or a feature? Or is there a solution, e.g. a overwritten equals-method of ConversionRule like this
equals-method:
  ... this.getClass() + this.clientId + this.subscriberId + this.inputValue  ...


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the hibernate-issues mailing list