Package org.hibernate.jdbc

Examples of org.hibernate.jdbc.Work


    protected boolean existsModulesTable() throws Exception {
        final boolean[] returnValue = {false};
        new HibernateTxFragment(true) {
        protected void txFragment(Session session) throws Exception {
            Work w = new Work() {
            public void execute(Connection connection) throws SQLException {
                // IMPORTANT NOTE: SQL Server driver closes the previous result set. So it's very important to read the
                // data from the first result set before opening a new one. If not an exception is thrown.
                DatabaseMetaData metaData = connection.getMetaData();
                returnValue[0] = metaData.getTables(null, null, installedModulesTable.toLowerCase(), null).next();
View Full Code Here


            return context;
        }

        public Map<String,Object> buildContext(HibernateTransaction tx) throws Exception {
            final Map<String,Object> ctx = new LinkedHashMap<String,Object>();
            tx.getSession().doWork(new Work() {
            public void execute(Connection conn) throws SQLException {

                // Generic
                ctx.put("Tx id", id);
                ctx.put(TX_ISOLATION, Integer.toString(conn.getTransactionIsolation()));
View Full Code Here

   * Fails on Oracle XE as well as on Oracle enterprise edition
   */
  @Ignore
  @Test
  public void canEvaluateDefaultSchema_usingPrepareCall() {
    this.emUtil.doWork(new Work() {
      @Override
      public void execute(Connection connection) throws SQLException {
        CallableStatement cs = connection.prepareCall("select sys_context( 'userenv', 'current_schema' ) from dual");
        ResultSet rs = cs.executeQuery();
        rs.next();
View Full Code Here

  @Test
  public void canImport_usingJdbcConnection() {
    DbSchemaUtil ds = new DbSchemaUtil(this.em);
    ds.prepareDefaultTestData(true, true, true);
   
    this.emUtil.doWork(new Work() {
      @Override
      public void execute(Connection connection) throws SQLException {
        URL url = JuUrl.resource("ch/inftec/ju/testing/db/DbDataUtilTest_jdbcConnectionImport.xml");
        DbDataUtil.executeInsert(connection, url, true);
      }
View Full Code Here

    return JuConnUtils.createByDbWorker(this);
  }
 
  @Override
  public void doWork(final DbWork work) {
    this.doWork(new Work() {
      @Override
      public void execute(Connection connection) throws SQLException {
        work.execute(connection);
      }
    });
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

        }
        entityManager.getTransaction().begin();
        logger.debug("Transaction started");
        session.doWork(new Work() {
            public void execute(Connection connection) throws SQLException {
                logger.debug("The connection instance is {}", connection);
                logger.debug("The isolation level of the connection is {} and the isolation level set on the transaction is {}",
                        connection.getTransactionIsolation(), definition.getIsolationLevel());
View Full Code Here

    s.close();

    assertEquals( "rollback() should not index", 3, getDocumentNumber() );

    s = getSessionFactory().openSession();
    s.doWork( new Work() {
      @Override
      public void execute(Connection connection) throws SQLException {
        connection.setAutoCommit( true ); // www.hibernate.org/403.html
      }
    } );
View Full Code Here

   * @throws SQLException in case the insert fails.
   */
  private TShirt createObjectWithSQL() throws SQLException {
    Session s = openSession();
    s.getTransaction().begin();
    s.doWork( new Work() {
      @Override
      public void execute(Connection connection) throws SQLException {
        final Statement statement = connection.createStatement();
        statement.executeUpdate(
            "insert into TShirt_Master(id, logo, size_, length_) values( 1, 'JBoss balls', 'large', 23.2)"
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.