Package org.hibernate

Examples of org.hibernate.Session.doWork()


    private void updateBlobs(final boolean isDispose) {
        final Set<HasBlob<?>> updates = (Set<HasBlob<?>>) env.get(HasBlob.GORM_UPDATE_SET);
        configureEnvironment();
        Session session = GrailsIntegration.getCurrentSession();
       
        session.doWork(new Work() {
            @Override
            public void execute(Connection conn) throws SQLException {
                boolean hasStoredKSession = false;
                for (final HasBlob<?> hasBlob : updates) {
                    if (!hasBlob.isDeleted()) {
View Full Code Here


  }

  public void testGeneralUsage() throws Throwable {
    Session session = openSession();
    session.beginTransaction();
    session.doWork(
        new Work() {
          public void execute(Connection connection) throws SQLException {
            // in this current form, users must handle try/catches themselves for proper resource release
            Statement statement = null;
            try {
View Full Code Here

  public void testSQLExceptionThrowing() {
    Session session = openSession();
    session.beginTransaction();
    try {
      session.doWork(
          new Work() {
            public void execute(Connection connection) throws SQLException {
              Statement statement = null;
              try {
                statement = connection.createStatement();
View Full Code Here

  }

  public void testDialectGetColumnAliasExtractor() throws Exception {
    Session session = openSession();
    session.beginTransaction();
    session.doWork(
        new Work() {
          public void execute(Connection connection) throws SQLException {
            PreparedStatement ps = connection.prepareStatement( QUERY_STRING );
            ResultSet rs = ps.executeQuery();
            try {
View Full Code Here

  public void testCreateAndDelete() {
    Date now = new Date();

    Session s = openSession();
    s.doWork(
        new Work() {
          public void execute(Connection connection) throws SQLException {
            // id -> java.util.Date (DATE - becase of explicit TemporalType)
            validateColumn( connection, "ID", java.sql.Types.DATE );
View Full Code Here

            throw new JizzBlobException("Failed to unwrap Hibernate Session "
                    + "from JPA EntityManager: " + th.getMessage(), th);
        }

        try {
            session.doWork(new org.hibernate.jdbc.Work() {
                @Override
                public void execute(Connection connection) throws SQLException {
                    try {
                        work.execute(connection);
                    } catch (Throwable th) {
View Full Code Here

    BillType.insertBillType("F", "Final");
    BillType.insertBillType("N", "Normal");
    BillType.insertBillType("W", "Withdrawn");
    Hiber.commit();

    s.doWork(new Work() {
      public void execute(Connection con) throws SQLException {
        try {
          CopyManager cm = new CopyManager(con
              .unwrap(BaseConnection.class));
          String[][] mddArray = {
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

  public void doWork(Work work) {
    // Flush the EntityManager to make sure we have all entities available
    this.em.flush();
   
    Session session = this.em.unwrap(Session.class);
    session.doWork(work);
  }
 
  /**
   * Executes some DB work that require a DataSource instance.
   * <p>
 
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

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.