I am using jboss app server 4.0.5 with the version of EJB3 that it ships with(I am
currently unable to upgrade due to project scheduling issues). When I use
SingleTableInheritance and a DiscriminatorFormula with string DiscriminatorValue's
that are not the same length and have more that one when clause in my DiscriminatorFormula
then hibernate appears to pad the the shorter DiscriminatorValues with spaces until they
are the length of the longest DiscriminatorValue. They then get WrongClassExceptions when
hibernate tries to resolve them to objects of the base class.
If I change the DiscriminatorValues to be all the same length then it works fine.
Here is an example of what does not work:
| @DiscriminatorFormula("case when DEFININGORG in ('VAC', 'AMTS')
then 'PROVIDER' when DEFININGORG='ST' then 'ST' else
'VENDOR' end")
| class Category
| {...}
|
| @DiscriminatorValue("PROVIDER")
| class ProviderCategory extends Category
| {...}
|
|
| @DiscriminatorValue("VENDOR")
| class VendorCategory extends Category
| {...}
|
|
| @DiscriminatorValue("ST")
| class STCategory extends Category
| {...}
|
It can only load ProviderCategory as a Category but get a WrongClassException when loading
any of the other ones. When I view the generated SQL in the logs, I notice that ST and
VENDOR are padded with spaces until they are the length of PROVIDER
However this works for all of them:
| @DiscriminatorFormula("case when DEFININGORG='ST' then 'S' when
DEFININGORG in ('VAC', 'AMTS') then 'P' else 'V'
end")
| class Category
| {...}
|
| @DiscriminatorValue("P")
| class ProviderCategory extends Category
| {...}
|
|
| @DiscriminatorValue("V")
| class VendorCategory extends Category
| {...}
|
|
| @DiscriminatorValue("S")
| class STCategory extends Category
| {...}
|
Has this been fixed?? I tried to search in the JIRA for DiscriminatorFormula but for some
reason my search did not come up with any results
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4177515#...
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&a...