I'm using ObjectDB but also want to make the collection inside a persisted object observable, so I have declared it this way:
@OneToMany(fetch=FetchType.EAGER, cascade=CascadeType.ALL) List<Widget> widgets = [] as ObservableList
Later on, I create a listener closure and attach it:
def widgetChangeListener = {
log.debug "WIDGET CHANGE: $it"
}
widgets.addPropertyChangeListener(widgetChangeListener)
However, when I try to persist the collection, I get this error:
Attempt to store an instance of a non persistable type com.greymatter.strategy.Harness$_closure1 - field com.greymatter.strategy.Harness.widgetChangeListener (error 303)
Is there any way to make this collection persistable while keeping the closure volatile, so I can observe changes to it? ObjectDB has a @Transient annotation, but I'm not sure how to apply it to the closure. If I put it on the def of widgetChangeListener, I get a MissingMethodException.
Are ObjectDB and ObservableList mutually exclusive?