/**
  * 通过id删除对象
  *
  * @param id 需要删除的对象的主键id
  */
 public void delete(String id) {
   T data = (T) ((HibernateDao) DaoFactory.getDao("hibernate")).load(getDataClass(), id);
   // 当查询出的对象不为空时,才执行删除操作
   if (data != null) {
     delete(data);
   }
 }
Exemple #2
0
  /**
   * 解析数据关联关系
   *
   * @param list
   * @param fieldName
   * @param keyMethod
   * @param table
   * @param refKey
   * @param ids
   * @throws NoSuchFieldException
   * @throws NoSuchMethodException
   * @throws IllegalAccessException
   * @throws InvocationTargetException
   */
  private void parseReference(
      List<T> list,
      String fieldName,
      Method keyMethod,
      String table,
      String refKey,
      StringBuffer ids)
      throws NoSuchFieldException, NoSuchMethodException, IllegalAccessException,
          InvocationTargetException {
    Coupler<Entity> childCoupler = childCouplers.get(fieldName);
    Class<Entity> childClass = childCoupler.getClazz();
    TreeDao<Entity> childDao = DaoFactory.getTreeDao(childClass);

    String childSql = buildChildQuerySql(table, refKey, ids, ordersMap, fieldName);

    if (entityClass == childClass) {
      int count = dao.count(childSql);
      if (count == 0) {
        return;
      }
    }

    List<Entity> childEntities = childDao.queryForTree(childSql);

    Class<?> fileType = entityClass.getDeclaredField(fieldName).getType();
    if (fileType == List.class) {
      setListValue(list, keyMethod, fieldName, childEntities, childClass, refKey);
    } else {
      setSingleValue(list, keyMethod, fieldName, childEntities, childClass, fileType, refKey);
    }
  }
Exemple #3
0
 public SimpleTreeDao(Class<T> clazz) {
   this.entityClass = clazz;
   dao = DaoFactory.getDao(entityClass);
   treeCoupler = CouplerFactory.getTreeCoupler(entityClass);
   coupler = treeCoupler.getCoupler();
   childCouplers = treeCoupler.getChildCouplers();
   oneToOneMap = coupler.getOneToOneMap();
   oneToManyMap = coupler.getOneToManyMap();
   manyToOneMap = coupler.getManyToOneMap();
   ordersMap = coupler.getOrdersMap();
 }
    public void onCreate(SQLiteDatabase sqlitedatabase)
    {
        super._01_(sqlitedatabase);
        Object obj = DaoFactory.access$000(DaoFactory.getInstance()).WritableDatabase();
        if (((SQLiteDatabase) (obj)).getVersion() == 147)
        {
            DaoMaster.createAllTables(((SQLiteDatabase) (obj)), true);
            DaoSession daosession = (new DaoMaster(sqlitedatabase)).newSession(IdentityScopeType.Session);
            sqlitedatabase = (new DaoMaster(((SQLiteDatabase) (obj)))).newSession(IdentityScopeType.Session).getPedometerMinuteDataDao();
            obj = daosession.getPedometerMinuteDataDao();
            PedometerMinuteData pedometerminutedata;
            for (Iterator iterator = sqlitedatabase.loadAll().iterator(); iterator.hasNext(); ((PedometerMinuteDataDao) (obj)).insertOrReplace(pedometerminutedata))
            {
                pedometerminutedata = (PedometerMinuteData)iterator.next();
                sqlitedatabase.detach(pedometerminutedata);
            }

        }
        DaoMaster.dropAllTables(DaoFactory.access$000(DaoFactory.getInstance()).WritableDatabase(), true);
    }
 public static void main(String[] args) {
   NewsDao newsDao = (NewsDao) DaoFactory.getDao(NewsDao.class);
   try {
     Class clazz = Class.forName("com.wanczy.maxclachan.pojo.UserPojo");
     Method[] methods = clazz.getDeclaredMethods();
     Field[] fields = clazz.getDeclaredFields();
     for (Method m : methods) {
       System.out.println(m.getName());
     }
   } catch (ClassNotFoundException e) {
     e.printStackTrace();
   }
 }
 public int executeSQL(String sql) {
   return ((HibernateDao) DaoFactory.getDao("hibernate")).updateBySQL(sql);
 }
 public void delete(T data) {
   ((HibernateDao) DaoFactory.getDao("hibernate")).delete(data);
 }
 public void add(T data) {
   ((HibernateDao) DaoFactory.getDao("hibernate")).save(data);
 }
  public User findById(Long id) {

    return (DaoFactory.getInstance().getUserDao().findById(id));
  }
 public List<T> search(String hql, Object[] parameters) {
   return (List<T>) ((HibernateDao) DaoFactory.getDao("hibernate")).search(hql, parameters);
 }
 public List<T> search(PageRoll pageRoll) {
   return (List<T>) ((HibernateDao) DaoFactory.getDao("hibernate")).search(pageRoll);
 }
Exemple #12
0
 public List<Proposal> getAllProposals() throws ServiceException {
   return factory.getProposalDAO().getAll();
 }
Exemple #13
0
 public long createProposal(Proposal proposal) throws ServiceException {
   return factory.getProposalDAO().createProposal(proposal);
 }
 protected GenericDao() {
   this(DaoFactory.entityManagerFactoryInstance());
 }
 public T load(String id) {
   return (T) ((HibernateDao) DaoFactory.getDao("hibernate")).load(getDataClass(), id);
 }
 public T retrieve(String id) {
   return (T) ((HibernateDao) DaoFactory.getDao("hibernate")).retrieve(getDataClass(), id);
 }
Exemple #17
0
  public List<Proposal> getProposalsForCustomerId(long customerId) throws ServiceException {

    return factory.getProposalDAO().getForCustomerId(customerId);
  }
 public List<T> search(String hql) {
   return (List<T>) ((HibernateDao) DaoFactory.getDao("hibernate")).search(hql);
 }
Exemple #19
0
 public Proposal getProposalById(long proposalId) throws ServiceException {
   return factory.getProposalDAO().getById(proposalId);
 }
 public List<T> searchlist(PageRoll pageRoll, String withhql) {
   return (List<T>) ((HibernateDao) DaoFactory.getDao("hibernate")).searchlist(pageRoll, withhql);
 }
Exemple #21
0
 public void updateProposal(Proposal proposal) {
   factory.getProposalDAO().update(proposal);
 }