Re: Application identity ("custom keys") might be breaking queries for inheritance classes


Manuel Castillo <contact@...>
 

thank you Andy, using objectIdClass metadata on super classes solved the problem. I'm not sure if inheritance is not involved at all; performing some minor changes to the Key class (removing the hashCode and toString attributes and the final qualifiers) and to the super classes (replacing the Key key attribute for String id as in the Key class; with some minor modifications to the Key getters and setters) did the trick.

No modifications were necessary on any other classes which does not involve inheritance, DAOs or anywhere else.

I'm sorry for not adding any LOG reference, it seemed to me pretty straightfoward that adding a non-recognized data type on a Mongo's BasicDBOject will result in an exception; the code that follows the snippet I copied is:
DBObject foundObj = dbColl.findOne(query);

Which will result in a CodecConfigurationException when the key object class is not recognized by Mongo.

But after all, there is a way to get this to work, which is really good; but I'm not sure if the code should go all the way there with an invalid key (for mongo) or not wrapping the exception and telling that a objectId and/or attribute converter should be used.

Join main@datanucleus.groups.io to automatically receive all group messages.