| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||||
| PersistenceService |
|
| 0.0;0 |
| 1 | /* |
|
| 2 | * Copyright 2004 Chris Nelson |
|
| 3 | * |
|
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
|
| 5 | * you may not use this file except in compliance with the License. |
|
| 6 | * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 |
|
| 7 | * Unless required by applicable law or agreed to in writing, |
|
| 8 | * software distributed under the License is distributed on an "AS IS" BASIS, |
|
| 9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
| 10 | * See the License for the specific language governing permissions and limitations under the License. |
|
| 11 | */ |
|
| 12 | package org.trails.persistence; |
|
| 13 | ||
| 14 | import java.io.Serializable; |
|
| 15 | import java.util.Collection; |
|
| 16 | import java.util.List; |
|
| 17 | ||
| 18 | import org.trails.descriptor.IClassDescriptor; |
|
| 19 | ||
| 20 | public interface PersistenceService |
|
| 21 | { |
|
| 22 | ||
| 23 | public <T> T getInstance(Class<T> type, Serializable id); |
|
| 24 | ||
| 25 | <T> T loadInstance(final Class<T> type, Serializable id); |
|
| 26 | ||
| 27 | public <T> List<T> getAllInstances(Class<T> type); |
|
| 28 | ||
| 29 | public <T> List<T> getInstances(Class<T> type, int startIndex, int maxResults); |
|
| 30 | ||
| 31 | /** |
|
| 32 | * @return a List containing all the classes this persistence |
|
| 33 | * service knows about |
|
| 34 | */ |
|
| 35 | public List getAllTypes(); |
|
| 36 | ||
| 37 | public <T> T save(T instance); |
|
| 38 | ||
| 39 | public void remove(Object instance); |
|
| 40 | public void removeAll(Collection collection); |
|
| 41 | ||
| 42 | /** |
|
| 43 | * A convenience method for getting a singleton instance of specific type |
|
| 44 | * |
|
| 45 | * @param <T> Specific type of the entity |
|
| 46 | * @param type Type of singleton entity you want return |
|
| 47 | * @return Returns the singleton entity of requested type |
|
| 48 | */ |
|
| 49 | public <T> T getInstance(final Class<T> type); |
|
| 50 | ||
| 51 | Serializable getIdentifier(Object data, IClassDescriptor classDescriptor); |
|
| 52 | ||
| 53 | boolean isTransient(Object data, IClassDescriptor classDescriptor); |
|
| 54 | ||
| 55 | <T> T saveCollectionElement(String addExpression, T member, Object parent); |
|
| 56 | ||
| 57 | void removeCollectionElement(String removeExpression, Object member, Object parent); |
|
| 58 | ||
| 59 | } |