public void conc(ExtObjectContainer oc) { oc.queryByExample((new QueryNonExistantTestCase(true))); assertOccurrences(oc, QueryNonExistantTestCase.class, 0); Query q = oc.query(); q.constrain(new QueryNonExistantTestCase(true)); Assert.areEqual(0, q.execute().size()); }
/** * Loads an existing Config object from the database and adds any missing default values to it, * creates and stores a new one if none exists. * * @return The config object. */ public static Config loadOrCreate(WoT myWoT) { ExtObjectContainer db = myWoT.getDB(); synchronized (db.lock()) { Config config; ObjectSet<Config> result = db.queryByExample(Config.class); if (result.size() == 0) { Logger.debug(myWoT, "Creating new Config..."); config = new Config(myWoT); config.storeAndCommit(); } else { if (result.size() > 1) /* Do not throw, we do not want to prevent WoT from starting up. */ Logger.error(myWoT, "Multiple config objects stored!"); Logger.debug(myWoT, "Loaded config."); config = result.next(); config.initializeTransient(myWoT); config.setDefaultValues(false); } return config; } }