| 41 | /// |
| 42 | /// @author Shai Almog |
| 43 | public final class SQLMap { |
| 44 | private boolean verbose = true; |
| 45 | private Database db; |
| 46 | |
| 47 | private SQLMap() { |
| 48 | } |
| 49 | |
| 50 | /// Creates an SQL Map instance to the given database instance |
| 51 | /// |
| 52 | /// #### Parameters |
| 53 | /// |
| 54 | /// - `db`: the database connection instance |
| 55 | /// |
| 56 | /// #### Returns |
| 57 | /// |
| 58 | /// an instance of the SQL mapping |
| 59 | public static SQLMap create(Database db) { |
| 60 | SQLMap s = new SQLMap(); |
| 61 | s.db = db; |
| 62 | return s; |
| 63 | } |
| 64 | |
| 65 | private static String getColumnNameImpl(PropertyBase prop) { |
| 66 | String val = (String) prop.getClientProperty("cn1$sqlColumn"); |
| 67 | if (val == null) { |
| 68 | return prop.getName(); |
| 69 | } |
| 70 | return val; |
| 71 | } |
| 72 | |
| 73 | /// Sets the primary key for the component |
| 74 | /// |
| 75 | /// #### Parameters |
| 76 | /// |
| 77 | /// - `cmp`: the business object |
| 78 | /// |
| 79 | /// - `pk`: the primary key field |
| 80 | public void setPrimaryKey(PropertyBusinessObject cmp, Property pk) { |
| 81 | cmp.getPropertyIndex().putMetaDataOfClass("cn1$pk", pk.getName()); |
| 82 | } |
| 83 | |
| 84 | |
| 85 | /// Sets the primary key for the component and makes it auto-increment |
| 86 | /// |
| 87 | /// #### Parameters |
| 88 | /// |
| 89 | /// - `cmp`: the business object |
| 90 | /// |
| 91 | /// - `pk`: the primary key field |
| 92 | public void setPrimaryKeyAutoIncrement(PropertyBusinessObject cmp, Property pk) { |
| 93 | cmp.getPropertyIndex().putMetaDataOfClass("cn1$pk", pk.getName()); |
| 94 | cmp.getPropertyIndex().putMetaDataOfClass("cn1$autoinc", Boolean.TRUE); |
| 95 | } |
| 96 | |
| 97 | /// Sets the sql type for the column |
| 98 | /// |
| 99 | /// #### Parameters |
| 100 | /// |
nothing calls this directly
no outgoing calls
no test coverage detected