// 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; } }
// 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; } }