View Javadoc

1   /*
2    * Copyright 2004 Carlos Sanchez.
3    * 
4    * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5    * use this file except in compliance with the License. You may obtain a copy of
6    * the License at
7    * 
8    * http://www.apache.org/licenses/LICENSE-2.0
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12   * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13   * License for the specific language governing permissions and limitations under
14   * the License.
15   */
16  package net.sf.oness.common.model.dao;
17  
18  import java.io.Serializable;
19  
20  import net.sf.oness.common.model.bo.AuditableBusinessObject;
21  
22  /***
23   * Interface to be implemented by Data Access Objects that allow data auditing
24   * 
25   * @author Carlos Sanchez
26   * @version $Revision: 1.12 $
27   */
28  public interface AuditableDao {
29  
30      /***
31       * Find an object by its identifier. This should return only the specified
32       * entity, not the associated ones.
33       * 
34       * This method returns the same object passed as argument.
35       * 
36       * @param id
37       *            identifier
38       * @return the value with that id, may have properties not initialized
39       * @throws org.springframework.dao.DataRetrievalFailureException
40       *             if an object with that id doesn't exist
41       */
42      public AuditableBusinessObject findById(Serializable id);
43  
44      /***
45       * Create a new object, the id value will be ignored
46       * 
47       * @param value
48       * @return the value created (with id, transactionTime and needed properties
49       *         initialized)
50       */
51      public AuditableBusinessObject create(AuditableBusinessObject value);
52  
53      /***
54       * Update an object
55       * 
56       * @param value
57       *            value to update
58       * @return the updated value
59       * @throws org.springframework.dao.OptimisticLockingFailureException
60       *             if the value has been already updated or deleted
61       */
62      public AuditableBusinessObject update(AuditableBusinessObject value);
63  
64      /***
65       * Find an object and all related entities by its identifier.
66       * 
67       * @param id
68       *            identifier
69       * @return the value with that id and all properties initialized
70       * @throws org.springframework.dao.DataRetrievalFailureException
71       *             if an object with that id doesn't exist
72       */
73      public AuditableBusinessObject findWithDetails(Serializable id);
74  
75  }