/****************************************************************
 * Licensed to the Apache Software Foundation (ASF) under one   *
 * or more contributor license agreements.  See the NOTICE file *
 * distributed with this work for additional information        *
 * regarding copyright ownership.  The ASF licenses this file   *
 * to you under the Apache License, Version 2.0 (the            *
 * "License"); you may not use this file except in compliance   *
 * with the License.  You may obtain a copy of the License at   *
 *                                                              *
 *   http://www.apache.org/licenses/LICENSE-2.0                 *
 *                                                              *
 * Unless required by applicable law or agreed to in writing,   *
 * software distributed under the License is distributed on an  *
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
 * KIND, either express or implied.  See the License for the    *
 * specific language governing permissions and limitations      *
 * under the License.                                           *
 ****************************************************************/
package org.apache.james.mailbox.torque.om;

import java.sql.Connection;
import java.util.List;

import org.apache.torque.TorqueException;
import org.apache.torque.util.Criteria;

/**
 * The skeleton for this class was autogenerated by Torque on:
 * 
 * [Wed Sep 06 08:50:08 CEST 2006]
 * 
 * You should add additional methods to this class to meet the application
 * requirements. This class will only be generated as long as it does not
 * already exist in the output directory.
 *
 * @deprecated Torque implementation will get removed in the next release
 */
@Deprecated()
public class MailboxRowPeer extends
        org.apache.james.mailbox.torque.om.BaseMailboxRowPeer {

    private static final long serialVersionUID = -1906212927584890188L;

    public static MailboxRow retrieveByName(String name) throws TorqueException {
        Criteria c = new Criteria();
        c.add(MailboxRowPeer.NAME, name);
        List l = MailboxRowPeer.doSelect(c);
        if (l.size() == 0) {
            return null;
        } else if (l.size() == 1) {
            return (MailboxRow) l.get(0);
        } else {
            throw new TorqueException("More than 1 Mailbox found");
        }
    }

    public static void doInsert(MailboxRow obj) throws TorqueException {
        // obj.setPrimaryKey(doInsert(buildCriteria(obj)));
        doInsert(buildCriteria(obj));
        obj.setNew(false);
        obj.setModified(false);
    }

    public static void doInsert(MailboxRow obj, Connection con)
            throws TorqueException {
        // obj.setPrimaryKey(doInsert(buildCriteria(obj), con));
        doInsert(buildCriteria(obj), con);
        obj.setNew(false);
        obj.setModified(false);
    }

}
