Spigot MongoDB Java Object Builder 1.1

Utility class to directly load and save Java Objects from/to a MongoDB Database

  1. JoBa97 submitted a new resource:

    MongoDB Java Object Builder - Utility class to directly load and save Java Objects from/to a MongoDB Database

    Read more about this resource...
     
  2. Can you handle a compound object? An object containing other objects as its instance variables?
     
  3. Simple answer: yes.
    Example of a structure I'm using. (Interesting part is probably the Area array)
    http://paste.md-5.net/bayajoweke.java
    Recursion (e.g. saving an instance of an object in one if it's field) would cause a stack overflow though.
     
    #3 JoBa97, May 8, 2015
    Last edited: May 8, 2015
  4. why would it cause a stack overflow???

    I've written similar java program (not for a plugin) but using XML to serialize/deserialize an Object. I had to do recursive process and had to map every single primitive types, and any object types in to XML.

    If I have an object which has Map<ItemStack, List<Player>> as an instance, how does your plugin same this into MongoDB?
     
  5. you should use introspection so that the objects you can handle does not have to be a subclass of DBxxx.
     
  6. Probably going to do that if it turns out that there are people who are using this.

    Regarding your first question. A Map<ItemStack, List<Player>> could only be saved if you defined a TypeConverter for it, but that's not really a problem. Although saving the player object doesn't really make sense, you should rather save it's uuid.

    This project's goal to be a really simple and easy to use library rather than something complex and - for some people - confusing like Morphia
     
    #6 JoBa97, May 8, 2015
    Last edited: May 8, 2015
    • Like Like x 1