01: package simpleorm.data;
02:
03: import java.util.Iterator;
04:
05: /**
06: * Interface that a data provider implements.
07: */
08: public abstract class DConnection {
09:
10: //static ThreadLocal<DConnection> threadAdaptor = new ThreadLocal();
11:
12: /** Create a new instance for, eg. inserting. */
13: public abstract DRecordInstance newInstance(DRecordMeta meta);
14:
15: protected DRecordInstance newRawInstance(DRecordMeta meta,
16: Object bean) {
17: DRecordInstance rec = meta.newInstance();
18: setBean(rec, bean);
19: return rec;
20: }
21:
22: protected Object getBean(DRecordInstance rec) {
23: return rec.bean;
24: }
25:
26: /** Called by DConnection, NOT user */
27: protected void setBean(DRecordInstance rec, Object bean) {
28: rec.bean = bean;
29: }
30:
31: /**
32: * Low level insert, normally called by DataSet?
33: */
34: public abstract void insert(DRecordInstance record);
35:
36: public abstract void update(DRecordInstance record);
37:
38: //public abstract void delete(DRecordInstance record);
39:
40: /**
41: * Beware that Iterator hasNext logic is incompatible and worse than
42: * RecordSet next logic. But it is the Java standard. Beware hasNext
43: * may be called multipletimes per record (and is by JSTL foreach).
44: */
45: public abstract Iterator<DRecordInstance> executeQuery(DQuery query);
46:
47: public abstract boolean canLockRecords();
48: }
|