Package org.hibernate.jdbc

Examples of org.hibernate.jdbc.Work


      for ( long iterationIndex = 0; iterationIndex < iterationCount; iterationIndex++ ) {
        final long idOffset = initialOffset + ( iterationIndex * batchSize );
        final long idCount = initialOffset + ( iterationIndex * batchSize ) + batchSize - 1;

        Transaction tx = s.beginTransaction();
        s.doWork( new Work() {
          @Override
          public void execute(Connection connection) throws SQLException {
            PreparedStatement ps = connection.prepareStatement( sql );
            for ( long id = idOffset; id < idCount; id++ ) {
              batchCallback.initStatement( ps, id );
View Full Code Here


  @Test
  public void testBatchSize() throws Exception {
    FullTextSession s = Search.getFullTextSession( openSession() );
    Transaction tx = s.beginTransaction();
    final int loop = 14;
    s.doWork( new Work() {
      @Override
      public void execute(Connection connection) throws SQLException {
        for ( int i = 0; i < loop; i++ ) {
          Statement statmt = connection.createStatement();
            statmt.executeUpdate( "insert into Domain(id, name) values( + "
View Full Code Here

    tx.commit();
    s.close();

    s = Search.getFullTextSession( openSession() );
    s.getTransaction().begin();
    s.doWork( new Work() {
      @Override
      public void execute(Connection connection) throws SQLException {
        Statement stmt = connection.createStatement();
        stmt.executeUpdate( "update Email set body='Meet the guys who write the software'" );
        stmt.close();
      }
    } );
    s.doWork( new Work() {
      @Override
      public void execute(Connection connection) throws SQLException {
        //insert an object never indexed
        Statement stmt = connection.createStatement();
        stmt.executeUpdate( "insert into Email(id, title, body, header) values( + "
View Full Code Here

  }

  private Session getSessionWithAutoCommit() {
    Session s;
    s = openSession();
    s.doWork( new Work() {
      @Override
      public void execute(Connection connection) throws SQLException {
        connection.setAutoCommit( true );
      }
    } );
View Full Code Here

  @Test
  public void testManualIndexFlush() throws Exception {
    FullTextSession s = Search.getFullTextSession( openSession() );
    Transaction tx = s.beginTransaction();
    final int loop = 14;
    s.doWork( new Work() {
      @Override
      public void execute(Connection connection) throws SQLException {
        for ( int i = 0; i < loop; i++ ) {
          Statement statmt = connection.createStatement();
          statmt.executeUpdate( "insert into Domain(id, name) values( + "
View Full Code Here

  public void testObjectNotFound() throws Exception {
    Session session = openSession();
    Transaction tx = session.beginTransaction();

    session.doWork(
        new Work() {
          @Override
          public void execute(Connection connection) throws SQLException {
            Statement statement = connection.createStatement();
            statement.executeUpdate( "DELETE FROM Author where name = 'Charles Dickens'" );
            statement.close();
View Full Code Here

    @PersistenceContext
    private EntityManager em;


    public void truncate() {
        em.unwrap(Session.class).doWork(new Work() {
            @Override
            public void execute(final Connection connection) throws SQLException {
                connection.createStatement().execute("truncate table showcase_excel_data");
            }
        });
View Full Code Here

                                pageable,
                                ((BigInteger) countQuery.getSingleResult()).longValue());

                        model.addAttribute("resultPage", page);

                        em.unwrap(Session.class).doWork(new Work() {
                            @Override
                            public void execute(final Connection connection) throws SQLException {
                                PreparedStatement psst = connection.prepareStatement(sql);
                                ResultSetMetaData metaData = psst.getMetaData();
View Full Code Here

   * @return Data as returned by the callback function
   */
  public <T> T extractDatabaseMetaData(final DatabaseMetaDataCallback<T> action) {
    final DataHolder<T> res = new DataHolder<>();
   
    this.doWork(new Work() {
      @Override
      public void execute(Connection connection) throws SQLException {
        DatabaseMetaData metaData = connection.getMetaData();
        res.setValue(action.processMetaData(metaData));
      }
View Full Code Here

   * @return Catalog name
   */
  public String getConnectionCatalog() {
    final DataHolder<String> catalog = new DataHolder<>();
   
    this.doWork(new Work() {
      @Override
      public void execute(Connection connection) throws SQLException {
        catalog.setValue(connection.getCatalog());
      }
    });
View Full Code Here

TOP

Related Classes of org.hibernate.jdbc.Work

Copyright © 2018 www.massapicom. 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.