コード例 #1
0
 private void createDeliveryType(int number, String description) {
   DeliveryType type = new DeliveryType();
   type.setNumber(number);
   type.setDescription(description);
   XPersistence.getManager().persist(type);
   XPersistence.commit();
 }
コード例 #2
0
 private void setDefaultSchema(HttpServletRequest request) {
   String hibernateDefaultSchemaTab =
       (String) request.getSession().getAttribute("xava_hibernateDefaultSchemaTab");
   if (hibernateDefaultSchemaTab != null) {
     request.getSession().removeAttribute("xava_hibernateDefaultSchemaTab");
     XHibernate.setDefaultSchema(hibernateDefaultSchemaTab);
   }
   String jpaDefaultSchemaTab =
       (String) request.getSession().getAttribute("xava_jpaDefaultSchemaTab");
   if (jpaDefaultSchemaTab != null) {
     request.getSession().removeAttribute("xava_jpaDefaultSchemaTab");
     XPersistence.setDefaultSchema(jpaDefaultSchemaTab);
   }
 }
コード例 #3
0
  public void testConverterWithMetaSets() throws Exception {
    // Creating new
    execute("CRUD.new");
    setValue("invoice.year", "2002");
    setValue("invoice.number", "1");
    setValue("type.number", "1");
    setValue("number", "66");
    setValue("description", "JUNIT");
    setValue("distance", usesAnnotatedPOJO() ? "1" : "2"); // National, in database 'N'
    execute("CRUD.save");
    assertNoErrors();
    assertValue("invoice.year", "");
    assertValue("invoice.number", "");
    assertValue("type.number", "");
    assertValue("number", "");
    assertValue("description", "");
    assertValue("distance", usesAnnotatedPOJO() ? "" : "0");
    // Search just created
    setValue("invoice.year", "2002");
    setValue("invoice.number", "1");
    setValue("type.number", "1");
    setValue("number", "66");
    execute("CRUD.refresh");
    assertNoErrors();
    assertValue("invoice.year", "2002");
    assertValue("invoice.number", "1");
    assertValue("type.number", "1");
    assertValue("number", "66");
    assertValue("description", "JUNIT");
    assertValue("distance", usesAnnotatedPOJO() ? "1" : "2");
    assertNoErrors();

    // Verifying database value
    Query query =
        XPersistence.getManager()
            .createNativeQuery(
                "select d.distance from XAVATEST.Delivery as d where "
                    + "invoice_year=2002 and invoice_number=1 and type=1 and number=66");
    String distanceDB = (String) query.getSingleResult();
    assertEquals("distance in database incorrect", "N", distanceDB);

    // Delete
    execute("CRUD.delete");
    assertNoErrors();
    assertMessage("Delivery deleted successfully");
  }
コード例 #4
0
  public void testDeleteSelectedOnesAndOrderBy() throws Exception {
    // Creating new
    execute("CRUD.new");
    setValue("invoice.year", "2009");
    setValue("invoice.number", "1");
    setValue("type.number", "1");
    setValue("number", "1");
    setValue("description", "JUNIT");
    execute("CRUD.save");
    assertNoErrors();

    // To list mode and order
    execute("Mode.list");
    assertActions(listActions);
    execute("List.orderBy", "property=invoice.year"); // ascending
    execute("List.orderBy", "property=invoice.year"); // descending
    assertNoErrors();

    // Delete
    assertValueInList(0, "invoice.year", "2009");
    assertValueInList(0, "invoice.number", "1");
    assertValueInList(0, "type.number", "1");
    assertValueInList(0, "number", "1");

    checkRow(0);

    execute("CRUD.deleteSelected");
    assertNoErrors();
    assertRowUnchecked(0);

    // Verifying that it is deleted
    Query query =
        XPersistence.getManager()
            .createQuery(
                "from Delivery d where "
                    + "d.invoice.year=2009 and d.invoice.number=1 and d.type.number=1 and d.number=1");
    if (!query.getResultList().isEmpty()) {
      fail("Delivery would be deleted and it is not the case");
    }
  }
コード例 #5
0
 private void deleteDeliveryType(int number) {
   DeliveryType type = XPersistence.getManager().find(DeliveryType.class, number);
   XPersistence.getManager().remove(type);
   XPersistence.commit();
 }