예제 #1
0
 // User defined finders/Buscadores definidos por el usuario
 public static FilterBySubfamily findBy() throws javax.ejb.ObjectNotFoundException {
   if (XavaPreferences.getInstance().isJPAPersistence()) {
     javax.persistence.Query query =
         org.openxava.jpa.XPersistence.getManager().createQuery("from FilterBySubfamily as o");
     try {
       return (FilterBySubfamily) query.getSingleResult();
     } catch (Exception ex) {
       // In this way in order to work with Java pre 5
       if (ex.getClass().getName().equals("javax.persistence.NoResultException")) {
         throw new javax.ejb.ObjectNotFoundException(
             XavaResources.getString("object_not_found", "FilterBySubfamily"));
       } else {
         ex.printStackTrace();
         throw new RuntimeException(ex.getMessage());
       }
     }
   } else {
     org.hibernate.Query query =
         org.openxava.hibernate.XHibernate.getSession().createQuery("from FilterBySubfamily as o");
     FilterBySubfamily r = (FilterBySubfamily) query.uniqueResult();
     if (r == null) {
       throw new javax.ejb.ObjectNotFoundException(
           XavaResources.getString("object_not_found", "FilterBySubfamily"));
     }
     return r;
   }
 }
예제 #2
0
 // User defined finders/Buscadores definidos por el usuario
 public static Size findById(int id) throws javax.ejb.ObjectNotFoundException {
   if (XavaPreferences.getInstance().isJPAPersistence()) {
     javax.persistence.Query query =
         org.openxava.jpa.XPersistence.getManager()
             .createQuery("from Size as o where o.id = :arg0");
     query.setParameter("arg0", new Integer(id));
     try {
       return (Size) query.getSingleResult();
     } catch (Exception ex) {
       // In this way in order to work with Java pre 5
       if (ex.getClass().getName().equals("javax.persistence.NoResultException")) {
         throw new javax.ejb.ObjectNotFoundException(
             XavaResources.getString("object_not_found", "Size"));
       } else {
         ex.printStackTrace();
         throw new RuntimeException(ex.getMessage());
       }
     }
   } else {
     org.hibernate.Query query =
         org.openxava.hibernate.XHibernate.getSession()
             .createQuery("from Size as o where o.id = :arg0");
     query.setParameter("arg0", new Integer(id));
     Size r = (Size) query.uniqueResult();
     if (r == null) {
       throw new javax.ejb.ObjectNotFoundException(
           XavaResources.getString("object_not_found", "Size"));
     }
     return r;
   }
 }
 @SuppressWarnings("unchecked")
 public List<MessageBundleProperty> getModifiedProperties(
     int sortOrder, int sortField, int startingIndex, int pageSize) {
   String orderBy = "asc";
   if (sortOrder == SORT_ORDER_DESCENDING) {
     orderBy = "desc";
   }
   String sortFieldName = "id";
   if (sortField == SORT_FIELD_MODULE) {
     sortFieldName = "moduleName";
   }
   if (sortField == SORT_FIELD_PROPERTY) {
     sortFieldName = "propertyName";
   }
   if (sortField == SORT_FIELD_LOCALE) {
     sortFieldName = "locale";
   }
   if (sortField == SORT_FIELD_BASENAME) {
     sortFieldName = "baseName";
   }
   org.hibernate.Query query = null;
   String queryString =
       "from MessageBundleProperty where value != null order by " + sortFieldName + " " + orderBy;
   try {
     query = getSession().createQuery(queryString);
     query.setFirstResult(startingIndex);
     query.setMaxResults(pageSize);
     return query.list();
   } catch (HibernateException e) {
     throw new RuntimeException(e.getMessage(), e);
   }
 }