|
172 | 172 | * <p>### Dataset Changes |
173 | 173 | * <p>{@docVar:datasetChanges} |
174 | 174 | * <p>{@docTable:datasetChanges} |
| 175 | + * <p>### Query Generation |
| 176 | + * <p>Options for query generation. |
| 177 | + * <p>{@docTable:queryGeneration} |
175 | 178 | * <p>### Source Path Defaults |
176 | 179 | * <p>Defaults for the path expressions in `sourcePath`, also see [Source Path |
177 | 180 | * Syntax](#path-syntax). |
|
202 | 205 | * <p>Additional columns for CRUD inserts can be set by adding `{inserts=columnName=value}` |
203 | 206 | * after the table name. The value may be a constant or a function, for example |
204 | 207 | * `{inserts=id=gen_random_uuid()&featuretype='type1'}`. |
| 208 | + * <p>Also regarding CRUD, if a property with `role: ID` does match the primary key of the main |
| 209 | + * table, but it should not be automatically generated on insert, add `{generated=false}` to the |
| 210 | + * `sourcePath` of that property. |
205 | 211 | * <p>All table and column names must be unquoted identifiers. |
206 | 212 | * <p>Arbitrary SQL expressions for values are supported, for example to apply function calls. |
207 | 213 | * As an example, this `[EXPRESSION]{sql=$T$.length+55.5}` (instead of just `length`) would add |
208 | 214 | * a fixed amount to the length column. The prefix `$T$` will be replaced with the table alias. |
209 | | - * <p>### Query Generation |
210 | | - * <p>Options for query generation. |
211 | | - * <p>{@docTable:queryGeneration} |
| 215 | + * <p>### CRUD |
| 216 | + * <p>If the features of this provider should be mutated via the API, `datasetChanges.mode` has |
| 217 | + * to be set to `CRUD`. Also consider the following paragraphs to understand which adjustments |
| 218 | + * to the mapping might be necessary for your use case. |
| 219 | + * <p>#### Table types |
| 220 | + * <p><code> |
| 221 | + * - `main` Main tables represent the instances of a feature type. They are defined in the |
| 222 | + * upper-most `sourcePath` of a type. |
| 223 | + * - `secondary` Secondary tables are connected to main tables via joins, either directly or |
| 224 | + * through a chain of secondary and/or junction tables. |
| 225 | + * - `junction` Junction tables usually represent m:n relations. They only contain two foreign keys |
| 226 | + * of main and/or secondary tables. |
| 227 | + * </code> |
| 228 | + * <p>#### Primary keys |
| 229 | + * <p>It is expected that every main and secondary table has a primary key, and that the value |
| 230 | + * for the primary key is automatically generated on insert. Usually |
| 231 | + * `sourcePathDefaults.primaryKey` should match the primary key name from the database. If not |
| 232 | + * every table has the same primary key, it can be overridden, see [Source Path |
| 233 | + * Syntax](#source-path-syntax). |
| 234 | + * <p>In rare cases, when another column than the primary key is used in join conditions, the |
| 235 | + * `primaryKey` in the mapping needs to match that column and differ from the actual primary |
| 236 | + * key. An example would be a junction table that connects feature instances by id. |
| 237 | + * <p>#### Feature ids |
| 238 | + * <p>There are four variants for creating new feature ids on insert: |
| 239 | + * <p><code> |
| 240 | + * - **Primary key, auto-generated** The `sourcePath` of the property with `role: ID` matches |
| 241 | + * the `primaryKey` and new values are automatically generated on insert by the database. |
| 242 | + * - **Primary key, user-defined** The `sourcePath` of the property with `role: ID` matches the |
| 243 | + * `primaryKey` and has the flag `{generated=false}`, the value from the payload given by the |
| 244 | + * user is inserted. |
| 245 | + * - **Other column, auto-generated** The `sourcePath` of the property with `role: ID` does not |
| 246 | + * match the `primaryKey`, and the `sourcePath` of the main table has a matching `inserts` flag |
| 247 | + * with a generation function, e.g. `{inserts=id=gen_random_uuid()'}` (see [Source Path Syntax](#source-path-syntax)). |
| 248 | + * - **Other column, user-defined** The `sourcePath` of the property with `role: ID` does not match |
| 249 | + * the `primaryKey`, and the `sourcePath` of the main table does not have a matching `inserts` |
| 250 | + * flag, the value from the payload given by the user is inserted. |
| 251 | + * </code> |
212 | 252 | * @cfgPropertiesAdditionalDe ### Connection Info |
213 | 253 | * <p>Das Connection-Info-Objekt für SQL-Datenbanken wird wie folgt beschrieben: |
214 | 254 | * <p>{@docTable:connectionInfo} |
|
218 | 258 | * <p>### Datensatzänderungen |
219 | 259 | * <p>{@docVar:datasetChanges} |
220 | 260 | * <p>{@docTable:datasetChanges} |
| 261 | + * <p>### Query-Generierung |
| 262 | + * <p>Optionen für die Query-Generierung in `queryGeneration`. |
| 263 | + * <p>{@docTable:queryGeneration} |
221 | 264 | * <p>### SQL-Pfad-Defaults |
222 | 265 | * <p>Defaults für die Pfad-Ausdrücke in `sourcePath`, siehe auch |
223 | 266 | * [SQL-Pfad-Syntax](#path-syntax). |
|
254 | 297 | * <p>Zusätzliche Spalten für CRUD Inserts können durch den Zusatz `{inserts=Spaltenname=Wert}` |
255 | 298 | * nach dem Tabellennamen angegeben werden. Der Wert kann eine Konstante oder eine Funktion |
256 | 299 | * sein, z.B. `{inserts=id=gen_random_uuid()&featuretype='type1'}`. |
| 300 | + * <p>Auch im Hinblick auf CRUD: wenn eine Eigenschaft mit `role: ID` dem Primärschlüssel der |
| 301 | + * Haupttabelle entspricht, aber der Wert beim Einfügen nicht automatisch generiert werden soll, |
| 302 | + * dann ist für diese Eigenschaft in `sourcePath` das Flag `{generated=false}` anzugeben. |
257 | 303 | * <p>Alle Tabellen- und Spaltennamen müssen "unquoted Identifier" sein. |
258 | 304 | * <p>Beliebige SQL-Ausdrücke für Werte sind möglich, z.B. um Funktionsaufrufe anzuwenden. So |
259 | 305 | * würde z.B. dieser Ausdruck `[EXPRESSION]{sql=$T$.length+55.5}` (anstatt nur `length`) einen |
260 | 306 | * fixen Wert zur Längen-Spalte addieren. Der Präfix `$T$` wird durch den Tabellen-Alias |
261 | 307 | * ersetzt. |
262 | | - * <p>### Query-Generierung |
263 | | - * <p>Optionen für die Query-Generierung in `queryGeneration`. |
264 | | - * <p>{@docTable:queryGeneration} |
| 308 | + * <p>### CRUD |
| 309 | + * <p>Wenn die Features dieses Providers über die API verändert werden sollen, muss |
| 310 | + * `datasetChanges.mode` auf `CRUD` gesetzt werden. Außerdem sind die folgenden Absätze zu |
| 311 | + * beachten, um zu verstehen, welche Anpassungen am Mapping für den eigenen Anwendungsfall |
| 312 | + * notwendig sind. |
| 313 | + * <p>#### Tabellentypen |
| 314 | + * <p><code> |
| 315 | + * - `main` Haupttabellen repräsentieren die Instanzen einer Objektart. Sie sind im |
| 316 | + * obersten `sourcePath` einer Objektart definiert. |
| 317 | + * - `secondary` Sekundärtabellen sind über Joins mit Haupttabellen verbunden, entweder direkt |
| 318 | + * oder über eine Kette von Sekundär- und/oder Junction-Tabellen. |
| 319 | + * - `junction` Junction-Tabellen repräsentieren in der Regel m:n-Beziehungen. Sie enthalten |
| 320 | + * ausschließlich zwei Fremdschlüssel von Haupt- und/oder Sekundärtabellen. |
| 321 | + * </code> |
| 322 | + * <p>#### Primärschlüssel |
| 323 | + * <p>Es wird erwartet, dass jede Haupt- und Sekundärtabelle einen Primärschlüssel hat und dass |
| 324 | + * der Wert für den Primärschlüssel beim Einfügen automatisch generiert wird. In der Regel |
| 325 | + * sollte `sourcePathDefaults.primaryKey` dem Primärschlüssel aus der Datenbank entsprechen. |
| 326 | + * Wenn nicht jede Tabelle denselben Primärschlüssel hat, kann dieser überschrieben werden, |
| 327 | + * siehe [SQL-Pfad-Syntax](#sql-pfad-syntax). |
| 328 | + * <p>In seltenen Fällen, wenn in Join-Bedingungen eine andere Spalte als der Primärschlüssel |
| 329 | + * verwendet wird, muss der `primaryKey` im Mapping dieser Spalte entsprechen und sich vom |
| 330 | + * tatsächlichen Primärschlüssel unterscheiden. Ein Beispiel wäre eine Junction-Tabelle, die |
| 331 | + * Feature-Instanzen über deren Ids verbindet. |
| 332 | + * <p>#### Feature-Ids |
| 333 | + * <p>Es gibt vier Varianten, um bei Inserts neue Feature-Ids zu erzeugen: |
| 334 | + * <p><code> |
| 335 | + * - **Primärschlüssel, automatisch generiert** Der `sourcePath` der Eigenschaft mit `role: ID` |
| 336 | + * entspricht dem `primaryKey` und neue Werte werden beim Einfügen automatisch von der |
| 337 | + * Datenbank generiert. |
| 338 | + * - **Primärschlüssel, benutzerdefiniert** Der `sourcePath` der Eigenschaft mit `role: ID` |
| 339 | + * entspricht dem `primaryKey` und hat das Flag `{generated=false}`, der Wert aus dem |
| 340 | + * Payload wird eingefügt. |
| 341 | + * - **Andere Spalte, automatisch generiert** Der `sourcePath` der Eigenschaft mit `role: ID` |
| 342 | + * entspricht nicht dem `primaryKey`, und der `sourcePath` der Haupttabelle hat ein |
| 343 | + * entsprechendes `inserts`-Flag mit einer Generierungsfunktion, z.B. |
| 344 | + * `{inserts=id=gen_random_uuid()'}` (siehe [SQL-Pfad-Syntax](#sql-pfad-syntax)). |
| 345 | + * - **Andere Spalte, benutzerdefiniert** Der `sourcePath` der Eigenschaft mit `role: ID` |
| 346 | + * entspricht nicht dem `primaryKey`, und der `sourcePath` der Haupttabelle hat kein |
| 347 | + * entsprechendes `inserts`-Flag, der Wert aus der Nutzlast wird eingefügt. |
| 348 | + * </code> |
265 | 349 | * @ref:cfgProperties {@link de.ii.xtraplatform.features.sql.domain.ImmutableFeatureProviderSqlData} |
266 | 350 | * @ref:connectionInfo {@link de.ii.xtraplatform.features.sql.domain.ImmutableConnectionInfoSql} |
267 | 351 | * @ref:pool {@link de.ii.xtraplatform.features.sql.domain.ImmutablePoolSettings} |
|
0 commit comments