001: package simpleorm.core;
002:
003: import simpleorm.properties.*;
004:
005: /*
006: * Copyright (c) 2002 Southern Cross Software Limited (SCSQ). All rights
007: * reserved. See COPYRIGHT.txt included in this distribution.
008: */
009:
010: /** Contains all the constants used by SimpleORM. Implementing this
011: interface will automatically import these constants which is
012: convenient. All constants are prefixed to avoid conflicts.<p>
013:
014: Bit fields are longs to alow for growth and to trap type errors if
015: they are mixed up with other int parameters. For flags, the low order
016: short is used to verfiy the parameter -- each flag set has a different
017: lower short. Parameters that use them are named *_flags where * is the
018: prefix, eg. sfd_bitSet.<p>
019:
020: Wouldn't it be wonderful if Java supported 30 year old constructs such
021: as enumerations and sets!<p>
022:
023: Constants and methods suffixed <code>_unimp</code> have not yet been
024: implemented. When they are, the suffix will be removed.<p> */
025:
026: public interface SConstants extends SSimpleORMProperties {
027:
028: // static final String SIMPLEORM_VERSION Moved to SUte due to Java bugs.
029:
030: // ## Should validate. Also, option for non Create Table not null.
031: //static final long SFD_GROUP_1 = ; // user defined groupings.
032: //static final long SFD_GROUP_2 = ;
033:
034: /** SQY_: SimpleORM QuerY flags. Controls which fields are queried,
035: and how.*/
036: static final long SQY_ = 0x00000200;
037:
038: /** Causes only the primary key field(s) are queried. At least the
039: primary key field(s) are always queried. */
040: static final long SQY_PRIMARY_KEY = 0x00010200;
041:
042: /** Only query fields marked <code>SFD_DESCRIPTIVE</code>. */
043: static final long SQY_DESCRIPTIVE = 0x00020200;
044:
045: /** Include any columns that were marked SFD_UNQUERIED and so are not
046: normally retrieved. */
047: static final long SQY_UNQUERIED = 0x00040200;
048:
049: /* Only query fields marked SFD_GROUP_1 or _2. Primary keys are
050: always queried. */
051: //static final long SQY_GROUP_1 = 0x00100200;
052: //static final long SQY_GROUP_2 = 0x00200200;
053: /** Do not lock the record in the database. Must not be updated
054: unless subsequently requeired without this flag set.
055: See SQY_UNREPEATABLE_READ */
056: static final long SQY_READ_ONLY = 0x00800200;
057:
058: /** Use Optimistic locking. Ie. do not lock the record in the
059: database, but do remember the previous state of the row. If the
060: record is updated a check is made that the row has not been
061: updated by another session.*/
062: static final long SQY_OPTIMISTIC = 0x01000200;
063:
064: /** Retrieve the row from the Read Mostly cache. Use with caution
065: because the returned row might be quite stale. Must not be
066: updated.*/
067: static final long SQY_READ_MOSTLY_unimp = 0X02000200;
068:
069: /** Internal for DataLoader. Do not include Foreign key column
070: fields, just the references.*/
071: static final long SQY_NO_FOREIGN_KEYS = 0X04000200;
072:
073: /** Internal for queries. Do not include Reference fields, just
074: the fields that correspond to columns. */
075: static final long SQY_NO_REFERENCES = 0X08000200;
076:
077: /** Internal for queries. Do not include any generated keys. */
078: static final long SQY_NO_GENERATED_KEYS = 0X10000200;
079:
080: /** Optimization parameter to findOrCreate that causes SimpleORM to
081: assume that the the record does not already exist in the
082: database, and so does not do the initial <code>SELECT</code>.
083: Saves about 30%. If the record does in fact exist you will get a
084: duplicate key error when the record is flushed. */
085: static final long SQY_ASSUME_CREATE = 0X20000200;
086:
087: /**
088: * Prevents a query from being issued to lazzily fetch a reference.
089: * getObject just returns Boolean.FALSE in this case. See
090: * getReferenceNoQuery.
091: */
092: static final long SQY_REFERENCE_NO_QUERY = 0x40000200;
093:
094: /**
095: * Read without locking the record with a read lock.
096: * Important for MS SQL to prevent lock escalation.
097: * For read behind dbs like Oracle/Postgresql this is the same as SQY_Read_Only
098: * in that no "FOR UPDATE" is appended, yet the record is still updatable
099: * (The read actually will probably be repeatable).<p>
100: *
101: * Note that this still enables the record to be updated.
102: * This is very dangerous unless you are <b>sure</b> that no other
103: * user could be accessing the records.
104: * Eg. Detail records related to a master.<p>
105: *
106: * But if you get this wrong you will get unrepeatable data
107: * corruption.
108: * See SQY_UNREPEATABLE_READ.
109: * And consider using optimistic locks if this really is a problem for you.
110: */
111: static final long SQY_UNREPEATABLE_READ_UNSAFE = 0x80000200;
112: /**
113: * Read without locking the record with a read lock.
114: * It is also Read_Only.<p>
115: *
116: * Note that it is still not really safe if you are using read
117: * data to update another record.<p>
118: *
119: * Important for MS SQL to prevent lock escalation.
120: * Has no effect for read behind dbs like Oracle/Postgresql.
121: */
122: static final long SQY_UNREPEATABLE_READ = SQY_UNREPEATABLE_READ_UNSAFE
123: | SQY_READ_ONLY;
124:
125: /** Values of SRecordInstance.bitSets -- ie. internal. */
126: static final byte INS_VALID = 0x01; // ie. Has been queried.
127: static final byte INS_READ_ONLY = 0x02; // ie. queried for update.
128: static final byte INS_DIRTY = 0x04;
129: // ie. has been set. But also may be true for primary keys iff they
130: // were retrieved via findOrCreate (vs select).
131:
132: }
|