[
http://opensource.atlassian.com/projects/hibernate/browse/HHH-1621?page=c...
]
Felipe Zschornack commented on HHH-1621:
----------------------------------------
I have the same problem. The select clause generated by Hibernate not consider the
discriminator column (this column is not part of the 'where' part of the select).
When Hibernate try to get the discriminator value, a erroneous key is used (in my case,
instead of discriminator key, the primary key was used), so
so the 'get' method of the subclassesByDiscriminatorValue HashMap
subclassesByDiscriminatorValue.get(value); (SingleTableEntityPersister.java:431)
will return 'null' instead of the correct discriminator value. This occurs in
final String result = persister.getSubclassForDiscriminatorValue( discriminatorValue );
(Loader.java:1441)
subclass mapping by discriminator - should instantiate parent for
unmapped discriminator values
-----------------------------------------------------------------------------------------------
Key: HHH-1621
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-1621
Project: Hibernate3
Type: Improvement
Components: core
Environment: 3.1.2
Sybase ASE 12.5.3
Reporter: Martin Schulz
Attachments: HHH-1621
Scenario: The parent class A has a discriminator field and some but all possible
scriminator values are mapped to subclasses.
Current behavior:
1) Default:
The following exception is thrown
org.hibernate.WrongClassException: Object with id: 10000 was not of the specified
subclass: A (Discriminator: D)
at org.hibernate.loader.Loader.getInstanceClass(Loader.java:1445)
[ the error itself is also quite misleading, as the row is exactly of / for the specified
class A. But there simply was no
subclass found ].
2) discriminator with force="true"
The parent class is never instantiated, only the mapped subclasses are instantiated.
Proposed behavior:
The parent class should be instantiated for those rows with unmapped discriminator
values.
Characteristics of proposed behavior:
- all rows in resultset would lead to instantiated class in the inheritence tree,
- the behavior would be in line with how joined-subclass behaves
- no caveat documentation required
Implementation:
(Easy)
in Loader.java, lines 1443ff, do not throw WrongClassException, but instead
return persister.getEntityName();
(Alternate)
change persister.getSubclassForDiscriminatorValue() implementations correspondingly.
Thx for your consideration / vote.
--
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....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira