Bela Borbely - 2013-01-26

Hi,

I want to use NeoDatis ODB as a object cache on a distributed system.

Data is stored in a SQL database on the server.
Client application retrieves data in the background through HTTP from the server application and updates the client side data.

I open ODB and call a odb.ext().replace(oid,object) if there is the object cached on the client side or call a plain store.
If I reload the same objects from the server, my database file has double size. Why?

try {
            ODB odb = ODBFactory.open("cache.neodatis");
            Map<Integer, OID> oids = new LinkedHashMap<Integer, OID>();
            Objects<Person> personsInTheCache = odb.getObjects(Person.class);
            while (personsInTheCache.hasNext()) {
                Person person = personsInTheCache.next();
                oids.put(person.getUID(), odb.getObjectId(person));
            }
            for (int i = 0; i < personsFromTheServer.size(); i++) {
                final Person person = personsFromTheServer.get(i);
                OID oid = oids.get(person.getUID());
                if (oid != null) {
                    odb.ext().replace(oid, person);
                } else {
                    odb.store(person);
                }
            }
            odb.commit();
            odb.close();
        } catch (Exception ex) {
            Logger.getLogger(App.class.getName()).log(Level.SEVERE, null, ex);
        }

So every client restart my database size increase, even if the objects are the same on the server side.
Is there any other method do refresh / reconnect objects from external system?

In advance, thanks for your answers!
Bela