⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 baseportletdbentrypeer.java

📁 jetspeed源代码
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
        {            throw new TorqueException(e);        }        catch (IllegalAccessException e)        {            throw new TorqueException(e);        }    }    /**     * Populates an object from a resultset row starting     * from a specified offset.  This is done so that you can select     * other rows than just those needed for this object.  You may     * for example want to create two objects from the same row.     *     * @throws TorqueException Any exceptions caught during processing will be     *         rethrown wrapped into a TorqueException.     */    public static void populateObject(Record row,                                      int offset,                                      PortletDbEntry obj)        throws TorqueException    {        try        {                obj.setId(row.getValue(offset + 0).asLong());                  obj.setName(row.getValue(offset + 1).asString());                  obj.setHidden(row.getValue(offset + 2).asBoolean());                  obj.setClassname(row.getValue(offset + 3).asString());                  obj.setType(row.getValue(offset + 4).asString());                  obj.setApplication(row.getValue(offset + 5).asBoolean());                  obj.setParentRef(row.getValue(offset + 6).asLong());                  obj.setURL(row.getValue(offset + 7).asString());                  obj.setCachedonurl(row.getValue(offset + 8).asBoolean());                  obj.setRole(row.getValue(offset + 9).asString());                  obj.setTitle(row.getValue(offset + 10).asString());                  obj.setDescription(row.getValue(offset + 11).asString());                  obj.setImage(row.getValue(offset + 12).asString());                  obj.setSecurityRef(row.getValue(offset + 13).asString());              }        catch (DataSetException e)        {            throw new TorqueException(e);        }    }    /**     * Method to do selects.     *     * @param criteria object used to create the SELECT statement.     * @return List of selected Objects     * @throws TorqueException Any exceptions caught during processing will be     *         rethrown wrapped into a TorqueException.     */    public static List doSelect(Criteria criteria) throws TorqueException    {        return populateObjects(doSelectVillageRecords(criteria));    }    /**     * Method to do selects within a transaction.     *     * @param criteria object used to create the SELECT statement.     * @param con the connection to use     * @return List of selected Objects     * @throws TorqueException Any exceptions caught during processing will be     *         rethrown wrapped into a TorqueException.     */    public static List doSelect(Criteria criteria, Connection con)        throws TorqueException    {        return populateObjects(doSelectVillageRecords(criteria, con));    }    /**     * Grabs the raw Village records to be formed into objects.     * This method handles connections internally.  The Record objects     * returned by this method should be considered readonly.  Do not     * alter the data and call save(), your results may vary, but are     * certainly likely to result in hard to track MT bugs.     *     * @throws TorqueException Any exceptions caught during processing will be     *         rethrown wrapped into a TorqueException.     */    public static List doSelectVillageRecords(Criteria criteria)        throws TorqueException    {        return BasePortletDbEntryPeer            .doSelectVillageRecords(criteria, (Connection) null);    }    /**     * Grabs the raw Village records to be formed into objects.     * This method should be used for transactions     *     * @param con the connection to use     * @throws TorqueException Any exceptions caught during processing will be     *         rethrown wrapped into a TorqueException.     */    public static List doSelectVillageRecords(Criteria criteria, Connection con)        throws TorqueException    {        if (criteria.getSelectColumns().size() == 0)        {            addSelectColumns(criteria);        }                          // check for conversion from boolean to int        if (criteria.containsKey(HIDDEN))        {            Object possibleBoolean = criteria.get(HIDDEN);            if (possibleBoolean instanceof Boolean)            {                if (((Boolean) possibleBoolean).booleanValue())                {                    criteria.add(HIDDEN, 1);                }                else                {                    criteria.add(HIDDEN, 0);                }            }         }                              // check for conversion from boolean to int        if (criteria.containsKey(APPLICATION))        {            Object possibleBoolean = criteria.get(APPLICATION);            if (possibleBoolean instanceof Boolean)            {                if (((Boolean) possibleBoolean).booleanValue())                {                    criteria.add(APPLICATION, 1);                }                else                {                    criteria.add(APPLICATION, 0);                }            }         }                              // check for conversion from boolean to int        if (criteria.containsKey(CACHEDONURL))        {            Object possibleBoolean = criteria.get(CACHEDONURL);            if (possibleBoolean instanceof Boolean)            {                if (((Boolean) possibleBoolean).booleanValue())                {                    criteria.add(CACHEDONURL, 1);                }                else                {                    criteria.add(CACHEDONURL, 0);                }            }         }                                            // Set the correct dbName if it has not been overridden        // criteria.getDbName will return the same object if not set to        // another value so == check is okay and faster        if (criteria.getDbName() == Torque.getDefaultDB())        {            criteria.setDbName(DATABASE_NAME);        }        // BasePeer returns a List of Value (Village) arrays.  The array        // order follows the order columns were placed in the Select clause.        if (con == null)        {            return BasePeer.doSelect(criteria);        }        else        {            return BasePeer.doSelect(criteria, con);        }    }    /**     * The returned List will contain objects of the default type or     * objects that inherit from the default.     *     * @throws TorqueException Any exceptions caught during processing will be     *         rethrown wrapped into a TorqueException.     */    public static List populateObjects(List records)        throws TorqueException    {        List results = new ArrayList(records.size());        // populate the object(s)        for (int i = 0; i < records.size(); i++)        {            Record row = (Record) records.get(i);              results.add(PortletDbEntryPeer.row2Object(row, 1,                PortletDbEntryPeer.getOMClass()));          }        return results;    }     /**     * The class that the Peer will make instances of.     * If the BO is abstract then you must implement this method     * in the BO.     *     * @throws TorqueException Any exceptions caught during processing will be     *         rethrown wrapped into a TorqueException.     */    public static Class getOMClass()        throws TorqueException    {        return CLASS_DEFAULT;    }    /**     * Method to do updates.     *     * @param criteria object containing data that is used to create the UPDATE     *        statement.     * @throws TorqueException Any exceptions caught during processing will be     *         rethrown wrapped into a TorqueException.     */    public static void doUpdate(Criteria criteria) throws TorqueException    {         BasePortletDbEntryPeer            .doUpdate(criteria, (Connection) null);    }    /**     * Method to do updates.  This method is to be used during a transaction,     * otherwise use the doUpdate(Criteria) method.  It will take care of     * the connection details internally.     *     * @param criteria object containing data that is used to create the UPDATE     *        statement.     * @param con the connection to use     * @throws TorqueException Any exceptions caught during processing will be     *         rethrown wrapped into a TorqueException.     */    public static void doUpdate(Criteria criteria, Connection con)        throws TorqueException    {        Criteria selectCriteria = new Criteria(DATABASE_NAME, 2);                   selectCriteria.put(ID, criteria.remove(ID));                            // check for conversion from boolean to int        if (criteria.containsKey(HIDDEN))        {            Object possibleBoolean = criteria.get(HIDDEN);            if (possibleBoolean instanceof Boolean)            {                if (((Boolean) possibleBoolean).booleanValue())                {                    criteria.add(HIDDEN, 1);                }                else                {                    criteria.add(HIDDEN, 0);                }            }         }                                          // check for conversion from boolean to int        if (criteria.containsKey(APPLICATION))        {            Object possibleBoolean = criteria.get(APPLICATION);            if (possibleBoolean instanceof Boolean)            {                if (((Boolean) possibleBoolean).booleanValue())                {                    criteria.add(APPLICATION, 1);                }                else                {                    criteria.add(APPLICATION, 0);                }            }         }                                          // check for conversion from boolean to int        if (criteria.containsKey(CACHEDONURL))        {            Object possibleBoolean = criteria.get(CACHEDONURL);            if (possibleBoolean instanceof Boolean)            {                if (((Boolean) possibleBoolean).booleanValue())                {                    criteria.add(CACHEDONURL, 1);                }                else                {                    criteria.add(CACHEDONURL, 0);                }            }         }                                                                    // Set the correct dbName if it has not been overridden        // criteria.getDbName will return the same object if not set to        // another value so == check is okay and faster        if (criteria.getDbName() == Torque.getDefaultDB())        {            criteria.setDbName(DATABASE_NAME);        }        if (con == null)        {            BasePeer.doUpdate(selectCriteria, criteria);        }        else        {            BasePeer.doUpdate(selectCriteria, criteria, con);        }    }    /**     * Method to do deletes.     *     * @param criteria object containing data that is used DELETE from database.     * @throws TorqueException Any exceptions caught during processing will be     *         rethrown wrapped into a TorqueException.     */     public static void doDelete(Criteria criteria) throws TorqueException     {         BasePortletDbEntryPeer            .doDelete(criteria, (Connection) null);     }    /**     * Method to do deletes.  This method is to be used during a transaction,     * otherwise use the doDelete(Criteria) method.  It will take care of     * the connection details internally.     *     * @param criteria object containing data that is used DELETE from database.     * @param con the connection to use     * @throws TorqueException Any exceptions caught during processing will be     *         rethrown wrapped into a TorqueException.     */     public static void doDelete(Criteria criteria, Connection con)        throws TorqueException     {                          // check for conversion from boolean to int        if (criteria.containsKey(HIDDEN))        {            Object possibleBoolean = criteria.get(HIDDEN);            if (possibleBoolean instanceof Boolean)            {                if (((Boolean) possibleBoolean).booleanValue())                {                    criteria.add(HIDDEN, 1);                }                else                {                    criteria.add(HIDDEN, 0);                }            }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -