Unable to store AtomicInteger


In the docs, all serializable types should be persistable. However, when I tried to persist a field of type AtomicInteger, I got the following message:

Message: Failed to commit transaction: Attempt to store an instance of a non persistable type java.util.concurrent.atomic.AtomicInteger

I am using ObjectDB 2.6. Is this a bug?


Serialization is disabled by default since it is not recommended (e.g. will make your database non portable to future non Java versions of ObjectDB), but can be enabled in the configuration if you must use it.

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

Well I must ensure thread-safety. Will this be a bad practice? Since this is not an entity class, the other alternative is to store an int then from the entity call an extra setup function in @PostLoad, which is very clunky in my opinion...is there another better way?

(I mean, if I know I will be working in Java, then there shouldn't be a problem, right?)


You may either use serialization or the PostLoad solution in this case.

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

Post Reply

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