Exemplo n.º 1
0
  public static void saveUpload(Reader csvFile, CSVStrategy strategy, ValueProcessorProvider vpp) {
    try {

      CSVReaderBuilder<Bank> builder = new CSVReaderBuilder<Bank>(csvFile);

      builder.strategy(strategy);
      CSVReader<Bank> csvReader =
          builder.entryParser(new AnnotationEntryParser<Bank>(Bank.class, vpp)).build();

      List<Bank> banks = csvReader.readAll();
      for (Bank bank : banks) {
        XPersistence.getManager().merge(bank);
      }

    } catch (Exception e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
  }
Exemplo n.º 2
0
 public static Product2 findByNumber(long number) throws NoResultException {
   Query query =
       XPersistence.getManager().createQuery("from Product2 as o where o.number = :number");
   query.setParameter("number", new Long(number));
   return (Product2) query.getSingleResult();
 }