Posts

Showing posts from June, 2012

Object Manager has been closed error

I recently faced this strange situation when datanculeus started throwing a "Object Manager has been closed" exception. This basically means I'm trying to detach the object in hand after the persistence manager was closed. But that wasn't the case at all ! However, regarding the way I solved this, here is my assumption. Even if:  Your field is included in the default fetch group ( defaultFetchGroup = "true" ) You enabled detachment on closing the persistence manager ( datanucleus.DetachOnClose=true ) You still have to keep the level 1 cache enabled in order for detachment to occur ! But in my case I had it disabled. Or you'll have to detach a copy of the object yourself after querying it.

Substituting SQL queried values by other values

Some times you need the queried values to be substituded by some other value just during the query time and not to actually change anything withing the database. SELECT      *,     CASE `emailnotificationsent`         WHEN 1 THEN 'true'         ELSE 0     END FROM     `brasresponse` ORDER BY `sequence` DESC It should be self explanatory.

Overriding datanucleus automatically generated id field

According to: http://www.datanucleus.org/products/accessplatform_3_0/jdo/datastore_identity.html If an persistable object doesn't have an id field, datanucleus will automatically generate an id field for. Oh and I hate that ! @DatastoreIdentity(column = "id", strategy = IdGeneratorStrategy.IDENTITY) //Nice, good looking auto-increment id field But what if that's not the whole view of the case ? I faced this situation when I had my object persisted within the graph of another objects. This case is datanucleus calls it, the compound identity. http://www.datanucleus.org/products/accessplatform_3_0/jdo/orm/compound_identity.html