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

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

Best Java code snippets using com.oberasoftware.jasdb.api.session.DBSessionFactory (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

@RequestMapping(value = "/{instanceId}/{bag}")
public String findAll(@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.getEntities(DEFAULT_PAGE_SIZE);
    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 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 testFindAll() throws Exception {
  DBSession session = sessionFactory.createSession();
  EntityManager entityManager = session.getEntityManager();
  try {
    entityManager.persist(new TestEntity(null, "Piet", "de Klos", newArrayList("cool stuff", "programming for dummies"), new HashMap<>()));
    entityManager.persist(new TestEntity(null, "Sjaak", "Gaar", newArrayList("darting", "programming for dummies"), new HashMap<>()));
    entityManager.persist(new TestEntity(null, "Klaas", "Vaak", newArrayList("cool stuff", "programming for dummies"), new HashMap<>()));
    entityManager.persist(new TestEntity(null, "Sjors", "Pineut", newArrayList("cool stuff", "darting"), new HashMap<>()));
    List<TestEntity> testEntities = entityManager.findEntities(TestEntity.class, QueryBuilder.createBuilder());
    assertThat(testEntities.size(), is(4));
    List<String> names = testEntities.stream().map(TestEntity::getFirstName).collect(Collectors.toList());
    assertThat(names, hasItems("Piet", "Sjaak", "Klaas", "Sjors"));
  } finally {
    session.closeSession();
    JasDBMain.shutdown();
  }
}
origin: oberasoftware/jasdb

@Test
public void testLimit() throws Exception {
  DBSession session = sessionFactory.createSession();
  EntityManager entityManager = session.getEntityManager();
  try {
    entityManager.persist(new TestEntity(null, "Piet", "de Klos", newArrayList("cool stuff", "programming for dummies"), new HashMap<>()));
    entityManager.persist(new TestEntity(null, "Sjaak", "Gaar", newArrayList("darting", "programming for dummies"), new HashMap<>()));
    entityManager.persist(new TestEntity(null, "Klaas", "Vaak", newArrayList("cool stuff", "programming for dummies"), new HashMap<>()));
    entityManager.persist(new TestEntity(null, "Sjors", "Pineut", newArrayList("cool stuff", "darting"), new HashMap<>()));
    List<TestEntity> testEntities = entityManager.findEntities(TestEntity.class, QueryBuilder.createBuilder(), 2);
    assertThat(testEntities.size(), is(2));
    List<String> names = testEntities.stream().map(TestEntity::getFirstName).collect(Collectors.toList());
    assertThat(names, hasItems("Piet", "Sjaak"));
  } finally {
    session.closeSession();
    JasDBMain.shutdown();
  }
}
origin: oberasoftware/jasdb

@Test
public void testDeleteInstance() throws JasDBException, IOException {
  DBSession session = sessionFactory.createSession();
  File instanceFolder = new File(storageLocation + "/.jasdb/myInstance");
  session.addAndSwitchInstance(MY_INSTANCE);
  assertEquals(MY_INSTANCE, session.getInstanceId());
  session.createOrGetBag(BAG_1);
  session.createOrGetBag("bag2");
  assertTrue(new File(instanceFolder, "bag1.pjs").exists());
  assertTrue(new File(instanceFolder, "bag2.pjs").exists());
  session.switchInstance("default");
  session.deleteInstance(MY_INSTANCE);
  assertFalse(new File(instanceFolder, "bag1.pjs").exists());
  assertFalse(new File(instanceFolder, "bag1.idx").exists());
  assertFalse(new File(instanceFolder, "bag2.pjs").exists());
  assertFalse(new File(instanceFolder, "bag2.idx").exists());
}
origin: oberasoftware/jasdb

  @Test
  public void testBagRemoveInstance() throws JasDBException, IOException {
    DBSession session = sessionFactory.createSession();
    File newInstanceFolder = new File(storageLocation + "/.jasdb/myInstance");
    session.addAndSwitchInstance(MY_INSTANCE);

    EntityBag bag = session.createOrGetBag("testbag1");
    bag.ensureIndex(new SimpleIndexField("field1", new StringKeyType()), false);
    assertTrue(new File(newInstanceFolder, "testbag1.pjs").exists());
    assertTrue(new File(newInstanceFolder, "testbag1_field1ID.idx").exists());
    assertEquals(1, session.getBags().size());

    session.removeBag("testbag1");
    assertFalse(new File(newInstanceFolder, "testbag1.pjs").exists());
    assertFalse(new File(newInstanceFolder, "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

@Test
public void testEmptyCollections() throws Exception {
  DBSession session = sessionFactory.createSession();
  EntityManager entityManager = session.getEntityManager();
  try {
    String id = entityManager.persist(new TestEntity(null, "Piet", "de Klos", newArrayList(), new HashMap<>())).getInternalId();
    TestEntity entity = entityManager.findEntity(TestEntity.class, id);
    assertThat(entity, notNullValue());
    assertThat(entity.getFirstName(), is("Piet"));
    assertThat(entity.getLastName(), is("de Klos"));
    assertThat(entity.getHobbies().size(), is(0));
    assertThat(entity.getProperties().size(), is(0));
  } finally {
    session.closeSession();
    JasDBMain.shutdown();
  }
}
com.oberasoftware.jasdb.api.sessionDBSessionFactory

Javadoc

The session factory is capable of creation JasDB session

Most used methods

  • createSession
    Creates a session for the given instance and credentials

Popular in Java

  • Finding current android device location
  • compareTo (BigDecimal)
  • notifyDataSetChanged (ArrayAdapter)
  • startActivity (Activity)
  • InputStream (java.io)
    A readable source of bytes.Most clients will use input streams that read data from the file system (
  • Date (java.sql)
    A class which can consume and produce dates in SQL Date format. Dates are represented in SQL as yyyy
  • Timestamp (java.sql)
    A Java representation of the SQL TIMESTAMP type. It provides the capability of representing the SQL
  • Hashtable (java.util)
    A plug-in replacement for JDK1.5 java.util.Hashtable. This version is based on org.cliffc.high_scale
  • Executor (java.util.concurrent)
    An object that executes submitted Runnable tasks. This interface provides a way of decoupling task s
  • JComboBox (javax.swing)
  • CodeWhisperer alternatives
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