Tabnine Logo
DBSessionFactory.createSession
Code IndexAdd Tabnine to your IDE (free)

How to use
createSession
method
in
com.oberasoftware.jasdb.api.session.DBSessionFactory

Best Java code snippets using com.oberasoftware.jasdb.api.session.DBSessionFactory.createSession (Showing top 20 results out of 315)

origin: oberasoftware/jasdb

@RequestMapping(value = "/{instanceId}/delete", method = RequestMethod.GET)
public String deleteInstance(@PathVariable String instanceId) throws JasDBException {
  DBSession session = sessionFactory.createSession();
  session.deleteInstance(instanceId);
  return "redirect:/data/";
}
origin: oberasoftware/jasdb

@RequestMapping(value = "/{instanceId}/{bag}/delete", method = RequestMethod.GET)
public String deleteBag(@PathVariable String instanceId, @PathVariable String bag) throws JasDBException {
  DBSession session = sessionFactory.createSession(instanceId);
  session.removeBag(instanceId, bag);
  return "redirect:/data/";
}
origin: oberasoftware/jasdb

@Test(expected = JasDBException.class)
public void testGetNonExistingInstance() throws JasDBException, IOException {
  sessionFactory.createSession("myNotExistingInstance");
}
origin: oberasoftware/jasdb

@RequestMapping(value="/{instanceId}", method = RequestMethod.GET)
public String instanceData(@PathVariable String instanceId, Model model) throws JasDBException {
  DBSession session = sessionFactory.createSession(instanceId);
  model.addAttribute("bags", session.getBags(instanceId));
  return buildIndex(session, model);
}
origin: oberasoftware/jasdb

@RequestMapping(value = "/", method = RequestMethod.POST)
public String createInstance(@Valid WebInstance instance) throws JasDBException {
  DBSession session = sessionFactory.createSession();
  session.addInstance(instance.getName());
  return "redirect:/data/";
}
origin: oberasoftware/jasdb

@RequestMapping(value="/", method=RequestMethod.GET)
public String indexPage(Model model) throws JasDBException {
  DBSession session = sessionFactory.createSession();
  model.addAttribute("bags", session.getBags());
  return buildIndex(session, model);
}
origin: oberasoftware/jasdb

@RequestMapping(value="/{instanceId}/createBag", method = RequestMethod.POST)
public String createBag(Bag bag, @PathVariable String instanceId) throws JasDBException {
  DBSession session = sessionFactory.createSession(instanceId);
  session.createOrGetBag(bag.getName());
  return "redirect:/data/";
}
origin: oberasoftware/jasdb

@Test
public void addInstance() throws JasDBException, IOException {
  DBSession session = sessionFactory.createSession();
  session.addInstance(MY_INSTANCE);
  List<Instance> instanceList = session.getInstances();
  assertEquals(2, instanceList.size());
  session.createOrGetBag(MY_INSTANCE, "testbag");
  File instanceLocation = new File(storageLocation + "/.jasdb/myInstance");
  assertThat(instanceLocation.exists(), is(true));
  assertThat(new File(instanceLocation, "testbag.pjs").exists(), is(true));
}
origin: oberasoftware/jasdb

@Test
public void testBagCreateOrGet() throws JasDBException {
  DBSession session = sessionFactory.createSession();
  session.createOrGetBag("testbag1");
  assertTrue(new File(jasdbHome, "testbag1.pjs").exists());
  assertEquals(1, session.getBags().size());
}
origin: oberasoftware/jasdb

@RequestMapping(value = "/{instanceId}/createEntity", method = RequestMethod.POST)
public String createData(@Valid WebEntity entity, @PathVariable String instanceId) throws JasDBException {
  DBSession session = sessionFactory.createSession(instanceId);
  EntityBag entityBag = session.createOrGetBag(entity.getBag());
  entityBag.addEntity(SimpleEntity.fromJson(entity.getData()));
  return "redirect:/data/";
}
origin: oberasoftware/jasdb

@Test
public void testBagGetNonExisting() throws JasDBException {
  DBSession session = sessionFactory.createSession();
  assertNull(session.getBag("testbag1"));
  assertNull(session.getBag("testbag2"));
  assertEquals(0, session.getBags().size());
  assertFalse(new File(jasdbHome, "testbag1.pjs").exists());
  assertFalse(new File(jasdbHome, "testbag1.pjsm").exists());
  assertFalse(new File(jasdbHome, "testbag2.pjs").exists());
  assertFalse(new File(jasdbHome, "testbag2.pjsm").exists());
}
origin: oberasoftware/jasdb

@Test
public void testGetInstances() throws JasDBException {
  DBSession session = sessionFactory.createSession();
  List<Instance> instanceList = session.getInstances();
  assertEquals(1, instanceList.size());
  Instance instance = instanceList.get(0);
  assertEquals("default", instance.getInstanceId());
  assertEquals(jasdbHome, new File(instance.getPath()).toString());
}
origin: oberasoftware/jasdb

@Test
public void testBagRemove() throws JasDBException {
  DBSession session = sessionFactory.createSession();
  EntityBag bag = session.createOrGetBag("testbag1");
  bag.ensureIndex(new SimpleIndexField("field1", new StringKeyType()), false);
  assertTrue(new File(jasdbHome, "testbag1.pjs").exists());
  assertTrue(new File(jasdbHome, "testbag1_field1ID.idx").exists());
  assertEquals(1, session.getBags().size());
  session.removeBag("testbag1");
  assertFalse(new File(jasdbHome, "testbag1.pjs").exists());
  assertFalse(new File(jasdbHome, "testbag1_field1ID.idx").exists());
}
origin: oberasoftware/jasdb

@Test
public void testGetBagList() throws JasDBException, IOException {
  DBSession session = sessionFactory.createSession();
  session.addAndSwitchInstance(MY_INSTANCE);
  session.createOrGetBag(BAG_1);
  session.createOrGetBag("bag2");
  assertEquals(2, session.getBags().size());
  assertEquals(0, session.getBags("default").size());
  assertEquals(2, session.getBags(MY_INSTANCE).size());
}
origin: oberasoftware/jasdb

@RequestMapping(value = "/{instanceId}/{bag}", method = RequestMethod.POST)
public String searchFieldValue(SearchForm searchForm, @PathVariable String instanceId, @PathVariable String bag, Model model) throws JasDBException {
  DBSession session = sessionFactory.createSession(instanceId);
  EntityBag entityBag = session.getBag(bag);
  PageResult result = new PageResult();
  model.addAttribute("page", result);
  if(entityBag != null) {
    QueryResult queryResult = entityBag.find(QueryBuilder.createBuilder().field(searchForm.getField()).value(searchForm.getValue())).limit(DEFAULT_PAGE_SIZE).execute();
    result.setEntities(loadEntities(queryResult));
  } else {
    result.setMessage(String.format("Unable to load Bag: %s on instance: %s as it does not exist", bag, instanceId));
  }
  return "data/query";
}
origin: oberasoftware/jasdb

@Test
public void testCreateAndInsertEntities() throws JasDBException, IOException {
  DBSession session = sessionFactory.createSession();
  session.addInstance(MY_INSTANCE);
  EntityBag bag = session.createOrGetBag(MY_INSTANCE, BAG_1);
  bag.addEntity(new SimpleEntity().addProperty("test", "value"));
  QueryResult result = bag.getEntities();
  assertThat(result.size(), is(1l));
  Entity entity = result.next();
  assertThat(entity, notNullValue());
  assertThat(entity.getProperty("test").getFirstValue().toString(), is("value"));
}
origin: oberasoftware/jasdb

@Test
public void testCreateAndGetInstanceBag() throws JasDBException, IOException {
  DBSession session = sessionFactory.createSession();
  session.addInstance(MY_INSTANCE);
  session.createOrGetBag(MY_INSTANCE, BAG_1);
  //default instance should be null
  assertNull(session.getBag(BAG_1));
  assertNotNull(MY_INSTANCE, session.getBag(MY_INSTANCE, BAG_1));
}
origin: oberasoftware/jasdb

@Test
public void testBagFlush() throws JasDBException {
  DBSession session = sessionFactory.createSession();
  EntityBag bag = session.createOrGetBag("testbag");
  long sizeBefore = bag.getDiskSize();
  int TEST_SIZE = 1000;
  for(int i=0; i<TEST_SIZE; i++) {
    bag.addEntity(new SimpleEntity());
  }
  bag.flush();
  assertTrue(bag.getDiskSize() > sizeBefore);
}
origin: oberasoftware/jasdb

@Test
public void testSwitchInstance() throws JasDBException, IOException {
  DBSession session = sessionFactory.createSession();
  session.addInstance(MY_INSTANCE);
  assertEquals("default", session.getInstanceId());
  session.switchInstance(MY_INSTANCE);
  assertEquals(MY_INSTANCE, session.getInstanceId());
  session.addAndSwitchInstance("anotherInstance");
  assertEquals("anotherInstance", session.getInstanceId());
}
origin: oberasoftware/jasdb

@Test
public void testDeleteEmptyIndexValue() throws Exception {
  try {
    DBSession session = sessionFactory.createSession();
    EntityBag bag = session.createOrGetBag("somebag");
    bag.ensureIndex(new SimpleIndexField("field", new StringKeyType()), false);
    String id = bag.addEntity(new SimpleEntity().addProperty("anotherfield", "somevalue")).getInternalId();
    bag.removeEntity(id);
  } finally {
    JasDBMain.shutdown();
  }
}
com.oberasoftware.jasdb.api.sessionDBSessionFactorycreateSession

Javadoc

Creates a DB Session

Popular methods of DBSessionFactory

    Popular in Java

    • Updating database using SQL prepared statement
    • scheduleAtFixedRate (ScheduledExecutorService)
    • getContentResolver (Context)
    • setContentView (Activity)
    • BufferedInputStream (java.io)
      A BufferedInputStream adds functionality to another input stream-namely, the ability to buffer the i
    • ReentrantLock (java.util.concurrent.locks)
      A reentrant mutual exclusion Lock with the same basic behavior and semantics as the implicit monitor
    • Stream (java.util.stream)
      A sequence of elements supporting sequential and parallel aggregate operations. The following exampl
    • Reference (javax.naming)
    • XPath (javax.xml.xpath)
      XPath provides access to the XPath evaluation environment and expressions. Evaluation of XPath Expr
    • Reflections (org.reflections)
      Reflections one-stop-shop objectReflections scans your classpath, indexes the metadata, allows you t
    • Top Sublime Text plugins
    Tabnine Logo
    • Products

      Search for Java codeSearch for JavaScript code
    • IDE Plugins

      IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
    • Company

      About UsContact UsCareers
    • Resources

      FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
    Get Tabnine for your IDE now