01: /*
02: * Copyright 2006 Davide Deidda
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16:
17: /*
18: * Persistor.java
19: *
20: * Created on 8 aprile 2005, 19.36
21: */
22:
23: package it.biobytes.ammentos;
24:
25: import it.biobytes.ammentos.query.*;
26: import java.util.*;
27:
28: /**
29: *
30: * @author davide
31: */
32: public abstract class Persistor {
33: public abstract <T> void save(Class<T> c, T obj)
34: throws PersistenceException;
35:
36: public abstract <T> void save(Class<T> c, T obj, Transaction trans)
37: throws PersistenceException;
38:
39: public abstract <T> void delete(Class<T> c, T obj)
40: throws PersistenceException;
41:
42: public abstract <T> void delete(Class<T> c, T obj, Transaction trans)
43: throws PersistenceException;
44:
45: public abstract <T> boolean load(Class<T> c, T obj,
46: Object primaryKey) throws PersistenceException;
47:
48: public abstract <T> boolean load(Class<T> c, T obj,
49: Object primaryKey, Transaction trans)
50: throws PersistenceException;
51:
52: public abstract <T> EntityIterable<T> loadIterable(Class<T> c,
53: Query qry) throws PersistenceException;
54:
55: public abstract <T> EntityIterable<T> loadIterable(Class<T> c,
56: Query qry, Transaction trans) throws PersistenceException;
57:
58: public abstract <T> int count(Class<T> c, Query qry)
59: throws PersistenceException;
60:
61: public abstract <T> int count(Class<T> c, Query qry,
62: Transaction trans) throws PersistenceException;
63:
64: protected <T> void markAsLoaded(Class<T> c, T obj) {
65: Ammentos.currentContext().markAsLoaded(c, obj);
66: }
67:
68: protected <T> void unmarkAsLoaded(Class<T> c, T obj) {
69: Ammentos.currentContext().unmarkAsLoaded(c, obj);
70: }
71:
72: protected <T> boolean isLoaded(Class<T> c, T obj) {
73: return Ammentos.currentContext().isLoaded(c, obj);
74: }
75: }
|