@Test(expected = IllegalArgumentException.class) public void SaveAll() { session.saveAll(value, Long.valueOf(1l)); }
@Test(expected = IllegalArgumentException.class) public void SaveEntityWithoutId2() { // #576836 session.saveAll(new EntityWithoutId()); }
public void export() { SessionFactoryImpl sessionFactory = new SessionFactoryImpl(); sessionFactory.setConfiguration(new DefaultConfiguration(RDFSClass.class.getPackage(), OWLClass.class.getPackage())); sessionFactory.setRepository(repository); sessionFactory.initialize(); Session session = sessionFactory.openSession(); if (ontology != null) { Ontology ont = new Ontology(new UID(ontology)); if (ontologyImports != null) { for (String oimport : ontologyImports) { ont.addImport(new Ontology(new UID(oimport))); } } session.save(ont); } Map<UID, RDFSResource> resources = new HashMap<UID, RDFSResource>(); resources.put(RDF.List, new RDFSClass<RDFSResource>(RDF.List)); resources.put(RDF.first, new RDFProperty(RDF.first)); resources.put(RDF.rest, new RDFProperty(RDF.rest)); resources.put(RDF.type, new RDFProperty(RDF.type)); resources.put(RDFS.label, new RDFProperty(RDFS.label)); resources.put(RDFS.comment, new RDFProperty(RDFS.comment)); resources.put(RDFS.Resource, new RDFSClass<Object>(RDFS.Resource)); // process classes for (MappedClass mappedClass : configuration.getMappedClasses()) { processClass(session, mappedClass.getJavaClass(), resources); } // save resources session.saveAll(resources.values().toArray()); }
@Before public void setUp() { session.saveAll(new SimpleType("a"), new SimpleType("b"), new SimpleType("c"), new SimpleType("d")); }
@Test public void List_uses_Cache() { Session session = SessionUtil.openSession(Example.class); Example example1 = new Example(); Example example2 = new Example(); session.saveAll(example1, example2); Example var = Alias.alias(Example.class); List<Example> examples = session.from($(var)).list($(var)); assertTrue(examples.contains(example1)); assertTrue(examples.contains(example2)); }
@Before public void setUp() { session = SessionUtil.openSession(Note.class, Term.class); Term term = new Term(); term.meaning = "X"; Term term2 = new Term(); term2.meaning = "X"; Note note1 = new Note(); note1.basicForm = "A"; note1.lemma = "B"; note1.term = term; Note note2 = new Note(); note2.basicForm = "A"; note2.lemma = "B"; note2.term = term2; session.saveAll(term, term2, note1, note2); termId = term.id; note1Id = note1.id; note2Id = note2.id; session.clear(); System.out.println(); }
@Test public void List_populates_Cache() { Session session = SessionUtil.openSession(Example.class); Example example1 = new Example(); Example example2 = new Example(); session.saveAll(example1, example2); session.clear(); Example var = Alias.alias(Example.class); List<Example> examples = session.from($(var)).list($(var)); assertTrue(examples.contains(session.getById(example1.id, Example.class))); assertTrue(examples.contains(session.getById(example2.id, Example.class))); }
@Test public void ConstructorInjection() { Session session = SessionUtil.openSession(Child.class, Parent.class); Parent parent = new Parent(); Child child = new Child(parent); session.saveAll(parent, child); session.flush(); session.clear(); Child child2 = session.get(Child.class, child.id); assertNotNull(child2); assertEquals(child.id, child2.id); assertEquals(child.parent.id, child2.parent.id); }
@Before public void setUp() { session = SessionUtil.openSession(Note.class, Term.class, Comment.class); Term term = new Term(); term.meaning = "X"; Term term2 = new Term(); term2.meaning = "X"; Note note1 = new Note(); note1.basicForm = "A"; note1.lemma = "B"; note1.term = term; Note note2 = new Note(); note2.basicForm = "A"; note2.lemma = "B"; note2.term = term2; Comment comment1 = new Comment(); comment1.note = note1; Comment comment2 = new Comment(); comment2.note = note2; Comment comment3 = new Comment(); comment3.note = note2; Comment comment4 = new Comment(); comment4.note = note2; session.saveAll(term, term2, note1, note2, comment1, comment2, comment3, comment4); session.clear(); System.out.println(); }
@Test public void deepPaths() { NoteRevision rev1 = new NoteRevision(); NoteRevision rev2 = new NoteRevision(); Note note = new Note(); note.latestRevision = rev1; rev1.note = note; rev2.note = note; session.saveAll(note, rev1, rev2); NoteRevision noteVar = Alias.alias(NoteRevision.class); Predicate where = $(noteVar).eq($(noteVar.getNote().getLatestRevision())); assertEquals(1, session.from($(noteVar)).where(where).list($(noteVar)).size()); }
@Before public void init() { Company company = new Company(); company.name = "Example"; company.description = "In English"; Employee employee = new Employee(); employee.age = 30; employee.name = "John Doe"; employee.company = company; repository = new MiniRepository(); sessionFactory = new SessionFactoryImpl() { @Override public Iterable<Locale> getLocales() { return new LocaleIterable(locale, false); } }; sessionFactory.setRepository(repository); DefaultConfiguration configuration = new DefaultConfiguration(TEST.NS, Employee.class, Company.class, EmployeeInfo.class); // configuration.setFetchStrategies(Collections.<FetchStrategy>emptyList()); sessionFactory.setConfiguration(configuration); sessionFactory.initialize(); ids = newSession().saveAll(employee, company); }
@Test public void ConstructorInjection() { Session session = SessionUtil.openSession(Child.class, Parent.class); Parent parent = new Parent(); Child child = new Child(new BID(), parent); session.saveAll(parent, child); session.flush(); session.clear(); Child child2 = session.get(Child.class, child.id); assertNotNull(child2); assertEquals(child.id, child2.id); assertEquals(child.parent.id, child2.parent.id); }
@Before public void setUp() { Repository repository = new MiniRepository(); session = SessionUtil.openSession(repository, RDFSClass.class.getPackage(), OWLClass.class.getPackage()); RDFSClass<?> xsdString = new RDFSDatatype(XSD.stringType); // classes OWLClass cl1 = new OWLClass(class1); OWLClass cl2 = new OWLClass(class2); cl2.addSuperClass(cl1); cl2.setOneOf(Arrays.asList(new RDFSResource(new UID(TEST.NS, "res1")), new RDFSResource(new UID(TEST.NS, "res2")))); // properties RDFProperty p1 = new RDFProperty(prop1).addDomain(cl1).addRange(xsdString); RDFProperty p2 = new RDFProperty(prop2).addDomain(cl1).addRange(cl2); RDFProperty p3 = new RDFProperty(prop3); // restrictions Restriction res = new Restriction(); res.setOnProperty(p3); res.setCardinality(2); res.setSomeValuesFrom(xsdString); assertTrue(res.isDefined()); cl1.addSuperClass(res); session.saveAll(cl1, cl2, p1, p2, p3, res); session.flush(); session.clear(); }
@Test public void test() { Entity entity = new Entity(); entity.text1 = "a"; entity.text2 = "a"; Entity entity2 = new Entity(); entity2.text1 = "a"; entity2.text2 = "b"; session.saveAll(entity, entity2); Entity e1 = Alias.alias(Entity.class, "e1"); Entity e2 = Alias.alias(Entity.class, "e2"); assertEquals(1l, session.from($(e1)).where($(e1.getText1()).eq($(e1.getText2()))).count()); assertEquals(2l, session.from($(e1), $(e2)).where($(e1.getText1()).eq($(e2.getText1())), $(e1).ne($(e2))).count()); } }