Package org.hibernate.search

Examples of org.hibernate.search.FullTextSession.persist()


  @Test
  public void testCustomAnalyzersAppliedForFieldsAddedInClassBridge() throws Exception {
    FullTextSession fullTextSession = Search.getFullTextSession( openSession() );
    Transaction tx = fullTextSession.beginTransaction();
    fullTextSession.persist( new Foo() );
    tx.commit();
    fullTextSession.clear();

    String[] searchTokens = new String[] { "dog", "cat", "mouse" };
    for ( int i = 0; i < searchTokens.length; i++ ) {
View Full Code Here


  @Test
  public void testProjectionUnmappedFieldValues() throws ParseException, IOException {
    FullTextSession s = Search.getFullTextSession( openSession() );
    Transaction tx = s.beginTransaction();
    s.persist( new CalendarDay().setDayFromItalianString( "01/04/2011" ) );
    s.persist( new CalendarDay().setDayFromItalianString( "02/04/2011" ) );
    tx.commit();
    s.clear();

    tx = s.beginTransaction();
View Full Code Here

  @Test
  public void testProjectionUnmappedFieldValues() throws ParseException, IOException {
    FullTextSession s = Search.getFullTextSession( openSession() );
    Transaction tx = s.beginTransaction();
    s.persist( new CalendarDay().setDayFromItalianString( "01/04/2011" ) );
    s.persist( new CalendarDay().setDayFromItalianString( "02/04/2011" ) );
    tx.commit();
    s.clear();

    tx = s.beginTransaction();
    org.hibernate.search.FullTextQuery hibQuery = s.createFullTextQuery( new MatchAllDocsQuery(), CalendarDay.class );
View Full Code Here

  @Test
  public void testClassBridgeWithSingleField() throws Exception {
    FullTextSession fullTextSession = Search.getFullTextSession( openSession() );
    Transaction tx = fullTextSession.beginTransaction();
    fullTextSession.persist( new Bar() );
    tx.commit();
    fullTextSession.clear();

    TermQuery termQuery = new TermQuery( new Term( "classField", "dog" ) );
    FullTextQuery query = fullTextSession.createFullTextQuery( termQuery );
View Full Code Here

    team.setName( "ATL team" );

    // persist and index the test object
    FullTextSession fts = Search.getFullTextSession( openSession() );
    Transaction tx = fts.beginTransaction();
    fts.persist( team );
    tx.commit();
    fts.clear();

    // execute several search to show that the right tokenizers were applies
    tx = fts.beginTransaction();
View Full Code Here

    OrderLine orderLine = new OrderLine();
    orderLine.setName( "Sequoia" );

    FullTextSession s = Search.getFullTextSession( openSession() );
    Transaction tx = s.beginTransaction();
    s.persist( orderLine );
    tx.commit();

    s.clear();

    tx = s.beginTransaction();
View Full Code Here

    incorrect.getSubIncorrect().setName( "This is a name not a class" );

    FullTextSession s = Search.getFullTextSession( openSession() );
    Transaction tx = s.beginTransaction();
    try {
      s.persist( incorrect );
      s.flush();
      s.flushToIndexes();
      fail( "Incorrect bridge should fail" );
    }
    catch (BridgeException e) {
View Full Code Here

    incorrect.setSubIncorrect( new IncorrectGet.SubIncorrect() );
    incorrect.getSubIncorrect().setName( "This is a name not a class" );

    FullTextSession s = Search.getFullTextSession( openSession() );
    Transaction tx = s.beginTransaction();
    s.persist( incorrect );
    tx.commit();
    s.clear();
    tx = s.beginTransaction();
    final QueryBuilder builder = s.getSearchFactory().buildQueryBuilder().forEntity( IncorrectGet.class ).get();
    final Query query = builder.keyword().onField( "subIncorrect.name" ).matching( "name" ).createQuery();
View Full Code Here

    incorrect.setName( "test" );

    FullTextSession s = Search.getFullTextSession( openSession() );
    Transaction tx = s.beginTransaction();
    try {
      s.persist( incorrect );
      s.flush();
      s.flushToIndexes();
      fail( "Incorrect bridge should fail" );
    }
    catch (BridgeException e) {
View Full Code Here

    for ( int i = 0; i < loop; i++ ) {
      Email email = new Email();
      email.setId( (long) i + 1 );
      email.setTitle( "JBoss World Berlin" );
      email.setBody( "Meet the guys who wrote the software" );
      s.persist( email );
    }
    tx.commit();
    s.close();

    //check non created object does get found!!1
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.