/** * It is mostly same as {@link LitePal#find(Class, long)} but an isEager * parameter. If set true the associated models will be loaded as well. * <br> * Note that isEager will only work for one deep level relation, considering the query efficiency. * You have to implement on your own if you need to load multiple deepness of relation at once. * * @param modelClass * Which table to query and the object type to return. * @param id * Which record to query. * @param isEager * True to load the associated models, false not. * @return An object with found data from database, or null. */ public static <T> T find(Class<T> modelClass, long id, boolean isEager) { return Operator.find(modelClass, id, isEager); }
/** * Finds the record by a specific id. * * <pre> * Person p = LitePal.find(Person.class, 1); * </pre> * * The modelClass determines which table to query and the object type to * return. If no record can be found, then return null. <br> * * Note that the associated models won't be loaded by default considering * the efficiency, but you can do that by using * {@link LitePal#find(Class, long, boolean)}. * * @param modelClass * Which table to query and the object type to return. * @param id * Which record to query. * @return An object with found data from database, or null. */ public static <T> T find(Class<T> modelClass, long id) { return Operator.find(modelClass, id); }
/** * Finds the record by a specific id. * * <pre> * Person p = LitePal.find(Person.class, 1); * </pre> * * The modelClass determines which table to query and the object type to * return. If no record can be found, then return null. <br> * * Note that the associated models won't be loaded by default considering * the efficiency, but you can do that by using * {@link Operator#find(Class, long, boolean)}. * * @param modelClass * Which table to query and the object type to return. * @param id * Which record to query. * @return An object with found data from database, or null. */ public static <T> T find(Class<T> modelClass, long id) { return find(modelClass, id, false); }
@Override public void run() { synchronized (LitePalSupport.class) { final T t = find(modelClass, id, isEager); if (executor.getListener() != null) { Operator.getHandler().post(new Runnable() { @Override public void run() { executor.getListener().onFinish(t); } }); } } } };
value = Operator.find(modelInstance.getClass(), (long) value);
long associatedClassId = cursor.getLong(columnIndex); try { LitePalSupport associatedObj = (LitePalSupport) Operator.find( Class.forName(associationInfo.getAssociatedClassName()), associatedClassId);