Search code examples
groovydb4ogriffon

groovy domain objects in Db4O database


I'm using db4o with groovy (actually griffon). I'm saving dozen of objects into db4o objectSet and see that .yarv file size is about 11Mb. I've checked its content and found that it stores metaClass with all nested fields into every object. It's a waste of space.
Looking for the way to avoid storing of metaClass and therefore reduce the size of result .yarv file, since I'm going to use db4o to store millions of entities. Should I try callConstructors(true) db4o configuration? Think it would help? Any help would be highly appreciated.


Solution

  • As an alternative you can just store 'Groovy'-beans instances. Those are compiled down to regular Java-ish classes with no special Groovy specific code attached to them.

    Just like this:

    class Customer {
        // properties
        Integer id
        String name
        Address address
    
    }
    
    class Address{
        String street;
    }
    
        def customer = new Customer(id:1, name:"Gromit", address:new Address(street:"Fun"))