private void storeSeparately(FullTextSession s, ElectricalProperties ep) { Transaction tx = s.beginTransaction(); s.save( ep ); tx.commit(); }
private void createTestContractors() { Transaction tx = fullTextSession.beginTransaction(); fullTextSession.save( new Plumber( 1, "Bill the plumber" ) ); fullTextSession.save( new BrickLayer( 2, "Bill the brick layer", "Johnson" ) ); fullTextSession.save( new BrickLayer( 4, "Barny the brick layer", "Johnson" ) ); fullTextSession.save( new BrickLayer( 5, "Bart the brick layer", "Higgins" ) ); fullTextSession.save( new BrickLayer( 6, "Barny the brick layer", "Higgins" ) ); fullTextSession.save( new Thatcher( 3, "Bill the thatcher" ) ); tx.commit(); fullTextSession.clear(); }
private void createTestContractors() { Transaction tx = fullTextSession.beginTransaction(); fullTextSession.save( new BrickLayer( 2, "Bill the brick layer", "Johnson" ) ); fullTextSession.save( new BrickLayer( 4, "Barny the brick layer", "Johnson" ) ); fullTextSession.save( new BrickLayer( 5, "Bart the brick layer", "Higgins" ) ); fullTextSession.save( new BrickLayer( 6, "Barny the brick layer", "Higgins" ) ); tx.commit(); fullTextSession.clear(); }
private void prepEmployeeIndex(FullTextSession s) { Transaction tx = s.beginTransaction(); Employee e1 = new Employee( 1000, "Griffin", "ITech" ); s.save( e1 ); Employee e2 = new Employee( 1001, "Jackson", "Accounting" ); e2.setHireDate( new Date() ); s.save( e2 ); Employee e3 = new Employee( 1002, "Jimenez", "ITech" ); s.save( e3 ); Employee e4 = new Employee( 1003, "Stejskal", "ITech" ); s.save( e4 ); Employee e5 = new Employee( 1004, "Whetbrook", "ITech" ); s.save( e5 ); tx.commit(); }
private void indexTestData() { Transaction tx = fullTextSession.beginTransaction(); for ( Foo foo : testEntities ) { fullTextSession.save( foo ); } tx.commit(); fullTextSession.clear(); }
/** * Helper method creating test data for number holder. */ private void createTestNumbers() { Transaction tx = fullTextSession.beginTransaction(); NumberHolder holder = new NumberHolder( 1, 1 ); fullTextSession.save( holder ); holder = new NumberHolder( 1, 10 ); fullTextSession.save( holder ); holder = new NumberHolder( 1, 5 ); fullTextSession.save( holder ); holder = new NumberHolder( 3, 2 ); fullTextSession.save( holder ); tx.commit(); fullTextSession.clear(); }
@Before public void insertTestData() throws Exception { FullTextSession fullTextSession = Search.getFullTextSession( openSession() ); Transaction tx = fullTextSession.beginTransaction(); Territory novaScotia = new Territory( 1, "Nova Scotia" ); fullTextSession.save( novaScotia ); Territory alaska = new Territory( 2, "Alaska" ); fullTextSession.save( alaska ); Territory tierraDelFuego = new Territory( 3, "Tierra del Fuego" ); fullTextSession.save( tierraDelFuego ); fullTextSession.save( new Explorer( 1, 23, novaScotia, "Sam", "1st", "Seaman" ) ); fullTextSession.save( new Explorer( 2, 22, alaska, "Sam", "2nd", "Traveller" ) ); fullTextSession.save( new Explorer( 3, 22, tierraDelFuego, "Collin", "1st", "Conqueror" ) ); tx.commit(); fullTextSession.close(); }
private void writeOnMaster() { try (FullTextSession fullTextSession = master.openFullTextSession()) { Transaction transaction = fullTextSession.beginTransaction(); SimpleEmail simpleEmail = new SimpleEmail(); simpleEmail.to = "outher space"; simpleEmail.message = "anybody out there?"; fullTextSession.save(simpleEmail); transaction.commit(); storedEmailsCount++; } }
@Test @TestForIssue(jiraKey = "HSEARCH-1917") public void testEmptyStringFaceting() throws Exception { Car car = new Car( "", "red", 2500 ); fullTextSession.save( car ); }
@Test @TestForIssue(jiraKey = "HSEARCH-1917") public void testNullNumericFaceting() throws Exception { Car car = new Car( "honda", "yellow", null ); fullTextSession.save( car ); }
@Test @TestForIssue(jiraKey = "HSEARCH-1917") public void testNullStringFaceting() throws Exception { Car car = new Car( null, "yellow", 2500 ); fullTextSession.save( car ); }
/** * Saves a new test email */ private void storeEmail(String content) { SimpleEmail email = new SimpleEmail(); email.to = "complaints-office@world.com"; email.message = content; FullTextSession fullTextSession = node.openFullTextSession(); Transaction transaction = fullTextSession.beginTransaction(); fullTextSession.save(email); transaction.commit(); fullTextSession.close(); }
private void writeOnMaster() { FullTextSession fullTextSession = master.openFullTextSession(); try { Transaction transaction = fullTextSession.beginTransaction(); SimpleEmail simpleEmail = new SimpleEmail(); simpleEmail.to = "outher space"; simpleEmail.message = "anybody out there?"; fullTextSession.save(simpleEmail); transaction.commit(); storedEmailsCount++; } finally { fullTextSession.close(); } }
static FullTextSession prepareSomeData(SearchTestBase testCase) { FullTextSession fullTextSession = Search.getFullTextSession( testCase.openSession() ); fullTextSession.beginTransaction(); Nation france = new Nation( "France", "FR" ); fullTextSession.save( france ); Book ceylonBook = new Book(); ceylonBook.setTitle( "Ceylon in Action" ); ceylonBook.setFirstPublishedIn( france ); fullTextSession.save( ceylonBook ); fullTextSession.getTransaction().commit(); return fullTextSession; }
private void buildBoostedDescIndex(FullTextSession session) { Transaction tx = session.beginTransaction(); BoostedDescriptionLibrary l = new BoostedDescriptionLibrary(); l.setAuthor( "H.G. Wells" ); l.setTitle( "The Invisible Man" ); l.setDescription( "Scientist discovers invisibility and becomes insane." ); session.save( l ); l = new BoostedDescriptionLibrary(); l.setAuthor( "H.G. Wells" ); l.setTitle( "War of the Worlds" ); l.setDescription( "Martians invade earth to eliminate mankind." ); session.save( l ); tx.commit(); }
private void buildBoostedGetIndex(FullTextSession session) { Transaction tx = session.beginTransaction(); BoostedGetDescriptionLibrary l = new BoostedGetDescriptionLibrary(); l.setAuthor( "H.G. Wells" ); l.setTitle( "The Invisible Man" ); l.setDescription( "Scientist discovers invisibility and becomes insane." ); session.save( l ); l = new BoostedGetDescriptionLibrary(); l.setAuthor( "H.G. Wells" ); l.setTitle( "War of the Worlds" ); l.setDescription( "Martians invade earth to eliminate mankind." ); session.save( l ); tx.commit(); }
private void buildBoostedFieldIndex(FullTextSession session) { Transaction tx = session.beginTransaction(); BoostedFieldDescriptionLibrary l = new BoostedFieldDescriptionLibrary(); l.setAuthor( "H.G. Wells" ); l.setTitle( "The Invisible Man" ); l.setDescription( "Scientist discovers invisibility and becomes insane." ); session.save( l ); l = new BoostedFieldDescriptionLibrary(); l.setAuthor( "H.G. Wells" ); l.setTitle( "War of the Worlds" ); l.setDescription( "Martians invade earth to eliminate mankind." ); session.save( l ); tx.commit(); }
static FullTextSession prepareSomeData(SearchTestBase testCase) { FullTextSession fullTextSession = Search.getFullTextSession( testCase.openSession() ); fullTextSession.beginTransaction(); Nation france = new Nation( "France", "FR" ); fullTextSession.save( france ); Book ceylonBook = new Book(); ceylonBook.setTitle( "Ceylon in Action" ); ceylonBook.setFirstPublishedIn( france ); fullTextSession.save( ceylonBook ); Book hsBook = new Book(); hsBook.setTitle( "HibernateSearch in Action" ); hsBook.setFirstPublishedIn( france ); fullTextSession.save( hsBook ); Book thirdBook = new Book(); thirdBook.setTitle( "Le chateau de ma mère" ); thirdBook.setFirstPublishedIn( france ); fullTextSession.save( thirdBook ); Book fourthBook = new Book(); fourthBook.setTitle( "La gloire de mon père" ); fourthBook.setFirstPublishedIn( france ); fullTextSession.save( fourthBook ); fullTextSession.getTransaction().commit(); return fullTextSession; }
@Test public void testSingleResultFromDeviceIndex() { assertEquals(1, clusterSize(node, Toaster.class)); // index an entity: { FullTextSession fullTextSession = node.openFullTextSession(); Transaction transaction = fullTextSession.beginTransaction(); Toaster toaster = new Toaster("A1"); fullTextSession.save(toaster); transaction.commit(); fullTextSession.close(); verifyResult(node); } }
@Test public void testQueryOnAllEntities() throws Exception { FullTextSession s = Search.getFullTextSession( openSession() ); Transaction tx = s.beginTransaction(); Person person = new Person(); person.setName( "Jon Doe" ); s.save( person ); tx.commit(); tx = s.beginTransaction(); QueryParser parser = new QueryParser( "name", TestConstants.standardAnalyzer ); Query query = parser.parse( "name:foo" ); FullTextQuery hibQuery = s.createFullTextQuery( query ); try { hibQuery.list(); fail(); } catch (SearchException e) { assertTrue( "Wrong message", e.getMessage().contains( "Cannot query: there aren't any mapped entity" ) ); } tx.rollback(); s.close(); }