示例#1
0
 public void testMapSelection() throws Exception {
   // Drop
   removeAll(MapHolder.class);
   // Create
   MapHolder mapHolder = new MapHolder();
   Book book = new Book("Book of Bokonon", "9");
   HashMap meta = new HashMap();
   meta.put("meta1", new Author("Geordi", "LaForge"));
   meta.put("meta2", new Author("Data", ""));
   meta.put("meta3", new Author("Scott", "Montgomery"));
   meta.put("book", book);
   mapHolder.setMeta(meta);
   // Save
   getStore().save(mapHolder);
   // Select
   List result =
       getStore()
           .find(
               "find mapholder where mapholder.meta['book'](book)=book and book.title like 'Book%'");
   Assert.assertEquals(result.size(), 1);
   result =
       getStore()
           .find("find mapholder where mapholder.meta['book'](book)=book and book.title like '9'");
   Assert.assertEquals(result.size(), 0);
 }
示例#2
0
 public void testStringCaseSensitivenessInMaps() throws Exception {
   // Drop
   removeAll(MapHolder.class);
   // Create
   MapHolder mapHolder = new MapHolder();
   Book book = new Book("Book of Bokonon", "9");
   HashMap meta = new HashMap();
   meta.put("book", book);
   mapHolder.setMeta(meta);
   getStore().save(mapHolder);
   // Select
   List result =
       getStore().find("find mapholder where mapholder.meta['book']=book and book.isbn='9'");
   Assert.assertEquals(result.size(), 1);
   result = getStore().find("find mapholder where mapholder.meta['bOoK']=book and book.isbn='9'");
   Assert.assertEquals(result.size(), 0);
 }