Issue #2542: Enum fields are set to null and embeddable enum class does not show in explorer

Type: BugVersion: 2.8.2Priority: CriticalStatus: FixedReplies: 11
#1

I switched to version 2.8.2 and now it seems that my enum types are not recognized and the field in the related objects is set to null. This is highly critical because it will cause data loss! The enum type is also not listed in the explorer.

I am talking about an enum class, which implements another interface. My List property is defined with the interface and not the specific class. Maybe this is relevant.

public enum Role implements package.of.Role {
    ...
}

@ElementCollection(fetch = FetchType.EAGER) @Enumerated(EnumType.STRING)
private List<package.of.Role> roles = null;

#2

This has effect, when something in the explorer is edited and saved (with missing enum type in embeddable classes). It has also effect, if the related entity is saved. It seems the enum class got lost in the schema.

Could this be the case because the enum type has the same name as the interface (but different package)?

#3

I checked version control. The entity class and the related enum type have not been changed!

#4

If I check the explorer, the list entry is still there. However, the type is the interface (not the specific enum class) and the value is null.

#5

> Could this be the case because the enum type has the same name as the interface (but different package)?

This is possible, although there are no previous reports on this bug.

If you can isolate the issue and provide a simple test case that demonstrates it (following these instructions) we will address the issue with high priority, and hopefully provide the necessary fix as soon as possible.

ObjectDB Support
ObjectDB - Fast Object Database for Java (JPA/JDO)
#6

Please find attached the test case. I am not totally sure what is happening. The test case passes for both versions (2.7.4.b03 and 2.8.2), however, when I open the database in the explorer the field "entities" holds one value which is "null" and not .

Maybe this is a bug in the explorer?

Maybe the enum has to be embeddable?*

* it worked like this before!

#7

This answer replaces a wrong answer that was given previously and was deleted.

Thank you for this test case.

After investigation it seems that this is indeed an issue that mainly affects the Explorer.

The problem is that the Explorer doesn't have the information about the inheritance of the enum type from the interface (usually inheritance information is stored in the database, but not for enum types), and therefore cannot read the list with the enum values.

A simple workaround in this test case is to discard the interface and use the enum in the list directly.

ObjectDB Support
ObjectDB - Fast Object Database for Java (JPA/JDO)
#8

I'm very sorry but this problem did not exist in earlier versions! I cannot change my database structure in on my devices.

Because it did not exist before, this is a highly critical issue and it will lead to data loss for users updating to 2.8.2.

It must be possible to solve this, because it worked before?

#9

> this is a highly critical issue and it will lead to data loss for users updating to 2.8.2.

If this is indeed just an issue with the Explorer, as it seems now, then no data loss is expected.

> Because it did not exist before,

Just tried the Explorers of versions 2.7.4 and 2.8.1 and it seems that they behave exactly as version 2.8.2. Why do you think that anything has changed?

ObjectDB Support
ObjectDB - Fast Object Database for Java (JPA/JDO)
#10

Ah there were two replies. Ok, if it only affects the Explorer I could find a work-around.

However, I do not understand why in this case the explorer does not show the String value instead of null.

#11

Without getting into too much details, build 2.8.2_01 includes an attempt to solve this issue with an internal ObjectDB workaround, so you can try it. 

ObjectDB Support
ObjectDB - Fast Object Database for Java (JPA/JDO)
#12

Thanks, it seems to work. In the tree view it looks good in the list view it still shows null. However, if I click on null it opens and shows the fields of the type.


Post Reply

To post a reply and/or subscribe to update notifications - please login