You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
return"Generated "+ className +".java in "+ outputPath;
310
-
} catch (Exception e) {
311
-
return"Error generating POJO: "+ e.getMessage();
312
-
}
313
-
}
226
+
Tinystruct includes a built-in `generate` command that creates POJO classes and XML mapping files directly from your database schema. It automatically detects Java types from column definitions and adds the required import statements — no manual import specification is needed.
314
227
315
-
privateString toCamelCase(String snakeCase) {
316
-
StringBuilder result =newStringBuilder();
317
-
boolean nextUpper =false;
318
-
319
-
for (char c : snakeCase.toCharArray()) {
320
-
if (c =='_') {
321
-
nextUpper =true;
322
-
} else {
323
-
if (nextUpper) {
324
-
result.append(Character.toUpperCase(c));
325
-
nextUpper =false;
326
-
} else {
327
-
result.append(Character.toLowerCase(c));
328
-
}
329
-
}
330
-
}
331
-
332
-
return result.toString();
333
-
}
228
+
```bash
229
+
# Interactive mode — prompts for table names and output path
Copy file name to clipboardExpand all lines: en/database.md
+160Lines changed: 160 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -576,6 +576,166 @@ In the tinystruct framework, there are distinct methods for different database o
576
576
577
577
For clarity and precise control, it's recommended to use `append()` for inserts and `update()` for updates rather than relying on `save()`.
578
578
579
+
## Built-in POJO Generator
580
+
581
+
Tinystruct includes a built-in code generator that creates POJO classes and XML mapping files directly from your database schema. The generator supports **MySQL**, **MSSQL**, **SQLite**, and **H2** databases.
582
+
583
+
### Running the Generator
584
+
585
+
Use the `generate` CLI command to invoke the generator:
586
+
587
+
```bash
588
+
# Interactive mode — the generator will prompt for table names and output path
2.**Base path** — where to place Java files (default: auto-detected from your project's package structure)
601
+
602
+
### Automatic Package Imports
603
+
604
+
The generator **automatically detects** the Java types required by your table columns and adds the correct import statements to the generated POJO. You do not need to specify any packages manually.
605
+
606
+
The following type mappings are handled automatically:
0 commit comments