/*
 * testeInsert.java
 *
 * Created on 6 de Setembro de 2004, 01:48
 */
package locadora.main;

/**
 *
 * @author  Rafael
 */

import javax.jdo.*;
import locadora.*;
import java.util.*;
import java.io.*;
import locadora.core.Cliente;
import locadora.factory.*;

public class Insert {
    
   PersistenceManagerFactory pmf;
    /** Creates a new instance of testeInsert */
  
   public Insert() {
     Properties p = new Properties();
     try
     { 
         p.load(new FileInputStream("locadora.jdogenie"));
         pmf = JDOHelper.getPersistenceManagerFactory(p);
     }
     catch(Exception e)
     {
         e.printStackTrace();
     }
     
     new Factory(this.getClass()).stubInsertFilmes();
   }
    
   public void insert()
   {
   PersistenceManager pm = pmf.getPersistenceManager();
   Cliente cli = new Cliente();
   cli.setNome("Rafael");
   cli.setCPF("12456789");
   cli.setEndereco("abc");
   cli.setDevendo(true);
   pm.currentTransaction().begin();
   pm.makePersistent(cli);
   pm.currentTransaction().commit();
   pm.close();
   
   }
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Insert teste=new Insert();
        teste.insert();
        System.out.println("HELLO");
    }
    
}
