public void upload(Song song) throws Exception { em.persist( song ); initNewSong(); }
public void register(Member member) throws Exception { em.persist( member ); initNewMember(); }
@Before public void setUp() throws Exception { emf = Persistence.createEntityManagerFactory( PERSISTENCE_UNIT_NAME ); ftem = Search.getFullTextEntityManager( emf.createEntityManager() ); ftem.getTransaction().begin(); for ( LocalDate d = START; d.isBefore( END ); d = d.plusDays( 1 ) ) { ftem.persist( new EntityWithIdClass( d ) ); ftem.persist( new EntityWithEmbeddedId( d ) ); } ftem.getTransaction().commit(); assertThat( JobTestUtil.nbDocumentsInIndex( emf, EntityWithIdClass.class ) ).isEqualTo( 0 ); assertThat( JobTestUtil.nbDocumentsInIndex( emf, EntityWithEmbeddedId.class ) ).isEqualTo( 0 ); }
private void createArticles() { EntityTransaction tx = em.getTransaction(); tx.begin(); try { em.persist( article( 1, "Hibernate & Lucene", date( 4, Calendar.JULY, 2005 ) ) ); em.persist( article( 2, "Hibernate Search", date( 2, Calendar.SEPTEMBER, 2005 ) ) ); em.persist( article( 3, "Hibernate OGM", date( 4, Calendar.SEPTEMBER, 2005 ) ) ); em.persist( article( 4, "Hibernate", date( 4, Calendar.DECEMBER, 2005 ) ) ); em.persist( article( 5, "Hibernate Validator", date( 8, Calendar.SEPTEMBER, 2010 ) ) ); em.persist( article( 6, "Hibernate Core", date( 4, Calendar.SEPTEMBER, 2012 ) ) ); } finally { tx.commit(); em.clear(); } }
@Before @Override public void setUp() { super.setUp(); em = Search.getFullTextEntityManager( factory.createEntityManager() ); em.getTransaction().begin(); bretzel = new Bretzel( 23, 34 ); em.persist( bretzel ); em.getTransaction().commit(); em.clear(); }
for ( long i = 0; i < 1000; i++ ) { Clock clock = new Clock( Long.valueOf( i ), "Model cat A" + i, ( i % 2 == 0 ) ? "Seiko" : "Swatch", Long.valueOf( 2000 + i ) ); em.persist( clock );
for ( long i = 0; i < 1000; i++ ) { Clock clock = new Clock( Long.valueOf( i ), "Model cat A" + i, ( i % 2 == 0 ) ? "Seiko" : "Swatch", Long.valueOf( 2000 + i ) ); em.persist( clock );
em.persist( bretzel ); em.getTransaction().commit(); em.clear();
@Test public void testHibernateSearchJPAAPIUsage() throws Exception { final FullTextEntityManager ftem = Search.getFullTextEntityManager( getFactory().createEntityManager() ); ftem.getTransaction().begin(); final Insurance insurance = new Insurance(); insurance.setName( "Macif" ); ftem.persist( insurance ); ftem.getTransaction().commit(); ftem.clear(); ftem.getTransaction().begin(); final QueryBuilder b = ftem.getSearchFactory() .buildQueryBuilder() .forEntity( Insurance.class ) .get(); final Query lq = b.keyword().onField( "name" ).matching( "Macif" ).createQuery(); final FullTextQuery ftQuery = ftem.createFullTextQuery( lq, Insurance.class ); final List<Insurance> resultList = ftQuery.getResultList(); assertThat( getFactory().getPersistenceUnitUtil().isLoaded( resultList.get( 0 ) ) ).isTrue(); assertThat( resultList ).hasSize( 1 ); for ( Object e : resultList ) { ftem.remove( e ); } ftem.getTransaction().commit(); ftem.close(); }
{50.77650000, 6.08416667}, } ) { em.persist( new POI( cnt, "Test_" + cnt, c[0], c[1], "" ) ); ++cnt;