public class TorqueExecutor {
   public static void main(String[] args) throws Exception {
      boolean success = true;
      Connection con = null;
      try {
         Torque.init("Torque.properties");
         Shain shain;
         Criteria criteria = new Criteria();
         List list = ShainPeer.doJoinBusho(criteria);
         System.out.println("-----検索(JOIN)結果-----");
         for(int i = 0; i < list.size(); i++) {
            shain = (Shain)list.get(i);
            System.out.println("社員ID = " + shain.getShainId());
            System.out.println("社員名 = " + shain.getShainName());
            System.out.println("部署名 = "
               + shain.getBusho().getBushoName());
         }
         System.out.println("\n");
         con = Torque.getConnection(BushoPeer.DATABASE_NAME);
         // トランザクション処理の開始
         Transaction.begin(BushoPeer.DATABASE_NAME);
         // 挿入処理
         Busho busho = new Busho();
         busho.setBushoId(4);
         busho.setBushoName("営業部(Torque)");
         busho.setExtensionNum(9876);
         busho.save(con);
         displayBusho("挿入結果");
         // 更新処理
         busho.setExtensionNum(6789);
         busho.save(con);
         displayBusho("更新結果");
         // 削除処理
         busho = new Busho();
         criteria = new Criteria();
         criteria.add(BushoPeer.BUSHO_ID, 4);
         BushoPeer.doDelete(criteria, con);
         displayBusho("削除結果");
      } catch(Exception e) {
         success = false;
         throw e;
      } finally {
         if(success) {
            // コミット
            Transaction.commit(con);
         } else {
            // ロールバック
            Transaction.rollback(con);
         }
         // コンフィグレーションのリセット
         Torque.shutdown();
      }
   }