Open GoogleCodeExporter opened 9 years ago
Whilst obfuscating some of the business details, I edited the 7th line of the
stack trace. The edit was incomplete. Please ignore any miss-match between the
class name and the package details.
Original comment by ron.tuf...@gmail.com
on 10 Sep 2012 at 3:18
The issue stems from the fact that a Map (being an interface) does not have a
default constructor, and while Morphia was correctly assigning the constructor
for the concrete HashMap on the outer Map it was failing to resolve a
constructor for the inner Map. This was resulting in the NullPointerException.
After a lot of debugging and trying this and that, eventually I stumbled (with
the help of a colleague) on to the solution.
- Instead of using the @Property annotation use @Embedded. and
- Declare the the concrete HashMap and not use the Map interface
@Embedded("vehicles")
private HashMap<String, HashMap<String, Integer>> vehicles = new
HashMap<String, HashMap<String, Integer>>();
Specifying the concrete class in either the @Property or @Embedded annotation
did nothing to help resolve the constructor for the inner HashMap.
Original comment by ron.tuf...@gmail.com
on 11 Sep 2012 at 8:20
Original issue reported on code.google.com by
ron.tuf...@gmail.com
on 10 Sep 2012 at 3:15