ClassCastException when loading a simple entity

Hi guys,

I am encountering a problem in my business application that in my mind should not happen. I’m asking for your help in order to either fix it on my side or on yours.

I created a sample project that mirrors the exact model that I’m using in my application where it crashes.

My model is pretty simple: I have a base class named BaseClassType. Then two classes inherit it (TestType and TestClassType). Then I have a ONE_TO_MANY association between TestClassType and TestType.

Then I have a class named User which has a MANY_TO_ONE association with TestType class.

Finally I have a class named PowerUser that inherits User class. I don’t use in my sample project but the bug won’t reproduce without it… strange.

User entity’s view looks like this:
user_view

How to reproduce: When you’ll run my sample project please create a TestClassType entity and then please create a TestType entity linked with it.

Then please create an User. When you hit save this exception is thrown:
ClassCastException: com.company.sampletest.entity.TestType cannot be cast to com.company.sampletest.entity.TestClassType

Regards,
Andrei

SampleTest.zip (88.9 KB)

Hi,
Thank you for reporting the problem. We have created an issue.
As a workaround, in user-view set the fetch type to BATCH or UNDEFINED to the type property.

2 Likes

Hello,

Thank you for creating an issue and suggesting a workaround for the moment.

Regards,
Andrei

1 Like