buildframework/helium/sf/java/metadata/src/com/nokia/helium/metadata/DAO.java
changeset 628 7c4a911dc066
equal deleted inserted replaced
588:c7c26511138f 628:7c4a911dc066
       
     1 /*
       
     2  * Copyright (c) 2007-2008 Nokia Corporation and/or its subsidiary(-ies).
       
     3  * All rights reserved.
       
     4  * This component and the accompanying materials are made available
       
     5  * under the terms of the License "Eclipse Public License v1.0"
       
     6  * which accompanies this distribution, and is available
       
     7  * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8  *
       
     9  * Initial Contributors:
       
    10  * Nokia Corporation - initial contribution.
       
    11  *
       
    12  * Contributors:
       
    13  *
       
    14  * Description:  
       
    15  *
       
    16  */
       
    17 package com.nokia.helium.metadata;
       
    18 
       
    19 import java.io.Serializable;
       
    20 import java.util.List;
       
    21 
       
    22 /**
       
    23  * Interface to implement the Data Access Object pattern. 
       
    24  *
       
    25  * @param <T> the type of the object to persist.
       
    26  */
       
    27 public interface DAO<T> {
       
    28     
       
    29     /**
       
    30      * Find a particular T object based on it's id. 
       
    31      * @param id the id to look for.
       
    32      * @return the retrieved object, or null if not found.
       
    33      */
       
    34     T findById(Serializable id);
       
    35     
       
    36     /**
       
    37      * Finding all rows from the database.
       
    38      * @return the list of T objects.
       
    39      */
       
    40     List<T> findAll();
       
    41     
       
    42     /**
       
    43      * Persisting the data object from the database. 
       
    44      * @param data the object to persist
       
    45      */
       
    46     void persist(T data);
       
    47 
       
    48     /**
       
    49      * Removing the data object from the database.
       
    50      * @param data the row to be removed
       
    51      */
       
    52     void remove(T data);
       
    53 }