/** * Changes the parent LocationGroup's name to "Airport" */ private void updateLocationGroupName(FullTextSession fullTextSession) { final Transaction transaction = fullTextSession.beginTransaction(); LocationGroup group = fullTextSession.get( LocationGroup.class, 1L ); LocationGroup locationGroup = (LocationGroup) fullTextSession.merge( group ); locationGroup.setName( "Airport" ); transaction.commit(); }
/** * Update a non-indexed collection of an entity contained in a collection. No indexing work should be created. */ private void updateCatalogsCollection(FullTextSession fullTextSession, Catalog catalog) { final Transaction transaction = fullTextSession.beginTransaction(); Consumer consumer = new Consumer(); consumer.setName( "consumer" ); consumer.getCatalogs().add( catalog ); fullTextSession.persist( consumer ); catalog.getConsumers().add( consumer ); fullTextSession.merge( catalog ); transaction.commit(); }
@Test public void testExplicitIndexingIgnoresInterceptor() throws Exception { indexTestData(); Transaction tx = fullTextSession.beginTransaction(); for ( Foo foo : testEntities ) { Foo attachedFoo = (Foo) fullTextSession.merge( foo ); fullTextSession.index( attachedFoo ); } tx.commit(); FullTextQuery fullTextQuery = fullTextSession.createFullTextQuery( new MatchAllDocsQuery() ); assertEquals( "All test entities should be indexed", testEntities.size(), fullTextQuery.list().size() ); }
/** * Initialize the test data. * * @param fulltextSessionBuilder */ private void initializeData(FullTextSessionBuilder fulltextSessionBuilder) { FullTextSession fullTextSession = fulltextSessionBuilder.openFullTextSession(); try { final Transaction transaction = fullTextSession.beginTransaction(); LocationGroup group = new LocationGroup( "Floor 1" ); fullTextSession.persist( group ); for ( int i = 0; i < 5; i++ ) { Location location = new Location( "Room 10" + i ); fullTextSession.persist( location ); group.getLocations().add( location ); location.setLocationGroup( group ); fullTextSession.merge( group ); } transaction.commit(); } finally { fullTextSession.close(); } }
private void initializeData(FullTextSessionBuilder fulltextSessionBuilder) { FullTextSession fullTextSession = fulltextSessionBuilder.openFullTextSession(); try { final Transaction transaction = fullTextSession.beginTransaction(); Catalog catalog = new Catalog(); catalog.setCatalogId( 1L ); catalog.setName( "parts" ); fullTextSession.persist( catalog ); for ( int i = 0; i < 5; i++ ) { Item item = new Item(); item.setName( "battery" ); fullTextSession.persist( item ); CatalogItem catalogItem = new CatalogItem(); catalogItem.setCatalog( catalog ); catalogItem.setItem( item ); fullTextSession.persist( catalogItem ); item.getCatalogItems().add( catalogItem ); fullTextSession.merge( item ); catalog.getCatalogItems().add( catalogItem ); fullTextSession.merge( catalog ); } transaction.commit(); } finally { fullTextSession.close(); } }
@Override protected void execute(FullTextSession fts) { long bookId = getNextBookId(); long authorId = getNextAuthorId(); if ( ctx.testContext.verbose ) { if ( bookId % 100 == 0 ) { log( "InsertBookTask: bookId=" + bookId ); } } Book book = new Book(); book.setId( bookId ); book.setTitle( "title" + bookId ); book.setSummary( SUMMARIES[(int) ( bookId % SUMMARIES.length )] ); book.setRating( 0.0f ); book.setTotalSold( 0L ); book.setPublicationDate( DateUtils.addDays( PUBLICATION_DATE_ZERO, (int) ( bookId % 1000 ) ) ); book.getAuthors().add( new Author( authorId, "author" + authorId ) ); fts.merge( book ); }
Transaction tx = session.beginTransaction(); hermioneGranger = (Person) session.merge( hermioneGranger ); hermioneGranger.setAddress( privetDrive );
Transaction tx = session.beginTransaction(); privetDrive = (Address) session.merge( privetDrive ); privetDrive.setHouseNumber( 5 ); privetDrive.setFlatNumber( null );