public void testBroken() throws Exception {
    if (getDialect() instanceof Oracle9Dialect) return;
    Session s = openSession();
    Transaction t = s.beginTransaction();
    Broken b = new Fixed();
    b.setId(new Long(123));
    b.setOtherId("foobar");
    s.save(b);
    s.flush();
    b.setTimestamp(new Date());
    t.commit();
    s.close();

    s = openSession();
    t = s.beginTransaction();
    s.update(b);
    t.commit();
    s.close();

    s = openSession();
    t = s.beginTransaction();
    b = (Broken) s.load(Broken.class, b);
    t.commit();
    s.close();

    s = openSession();
    t = s.beginTransaction();
    s.delete(b);
    t.commit();
    s.close();
  }
 public static void deletarHorario(Horario horario) {
   session = (Session) PreparaSessao.pegarSessao();
   Transaction transaction = session.beginTransaction();
   Horario horarioDB = (Horario) session.load(Horario.class, horario.getId());
   session.delete(horarioDB);
   transaction.commit();
   // session.close();
 }
  // Método duplicado na classe MonitorDAO ver qual é o verdadeiro
  public static void adicionarMonitorAoHorario(long idHorario, Monitor monitor) {
    session = (Session) PreparaSessao.pegarSessao();
    session.beginTransaction();

    Horario horario = new Horario();
    session.load(horario, idHorario);
    horario.setMonitor(monitor);
    session.save(horario);
    session.getTransaction().commit();
    session.close();
  }
  public void testBlobClob() throws Exception {

    Session s = openSession();
    Blobber b = new Blobber();
    b.setBlob(Hibernate.createBlob("foo/bar/baz".getBytes()));
    b.setClob(Hibernate.createClob("foo/bar/baz"));
    s.save(b);
    // s.refresh(b);
    // assertTrue( b.getClob() instanceof ClobImpl );
    s.flush();
    s.refresh(b);
    // b.getBlob().setBytes( 2, "abc".getBytes() );
    b.getClob().getSubString(2, 3);
    // b.getClob().setString(2, "abc");
    s.flush();
    s.connection().commit();
    s.close();

    s = openSession();
    b = (Blobber) s.load(Blobber.class, new Integer(b.getId()));
    Blobber b2 = new Blobber();
    s.save(b2);
    b2.setBlob(b.getBlob());
    b.setBlob(null);
    // assertTrue( b.getClob().getSubString(1, 3).equals("fab") );
    b.getClob().getSubString(1, 6);
    // b.getClob().setString(1, "qwerty");
    s.flush();
    s.connection().commit();
    s.close();

    s = openSession();
    b = (Blobber) s.load(Blobber.class, new Integer(b.getId()));
    b.setClob(Hibernate.createClob("xcvfxvc xcvbx cvbx cvbx cvbxcvbxcvbxcvb"));
    s.flush();
    s.connection().commit();
    s.close();

    s = openSession();
    b = (Blobber) s.load(Blobber.class, new Integer(b.getId()));
    assertTrue(b.getClob().getSubString(1, 7).equals("xcvfxvc"));
    // b.getClob().setString(5, "1234567890");
    s.flush();
    s.connection().commit();
    s.close();

    /*InputStream is = getClass().getClassLoader().getResourceAsStream("jdbc20.pdf");
    s = sessionsopenSession();
    b = (Blobber) s.load( Blobber.class, new Integer( b.getId() ) );
    System.out.println( is.available() );
    int size = is.available();
    b.setBlob( Hibernate.createBlob( is, is.available() ) );
    s.flush();
    s.connection().commit();
    ResultSet rs = s.connection().createStatement().executeQuery("select datalength(blob_) from blobber where id=" + b.getId() );
    rs.next();
    assertTrue( size==rs.getInt(1) );
    rs.close();
    s.close();

    s = sessionsopenSession();
    b = (Blobber) s.load( Blobber.class, new Integer( b.getId() ) );
    File f = new File("C:/foo.pdf");
    f.createNewFile();
    FileOutputStream fos = new FileOutputStream(f);
    Blob blob = b.getBlob();
    byte[] bytes = blob.getBytes( 1, (int) blob.length() );
    System.out.println( bytes.length );
    fos.write(bytes);
    fos.flush();
    fos.close();
    s.close();*/

  }