@@ -5,26 +5,70 @@ Command line utility for generating Java code and DDL from a set of models defin
5
5
This is not intended to be a full fledged ORM framework. Instead, the goal is to help jumpstart new projects by
6
6
providing a simple utility for stubbing out code and SQL.
7
7
8
+ ## Command Line Interface
9
+ The javaxt-orm library provides a command line interface that can be used to generate Java classes
10
+ and schema. All you need to do is provide a input model and an output directory. Example:
11
+ ```
12
+ java -jar javaxt-orm.jar /path/to/model.js /output
13
+ ```
14
+
15
+ ## Model Input
16
+ Below is a simple example of an input Javascript file with an Address model.
17
+ ``` javascript
18
+ var package = " com.example.models" ;
19
+ var models = {
20
+ Address: {
21
+ fields: [
22
+ {name: ' street' , type: ' string' },
23
+ {name: ' city' , type: ' string' },
24
+ {name: ' state' , type: ' string' },
25
+ {name: ' postalCode' , type: ' string' },
26
+ {name: ' coordinates' , type: ' geo' }
27
+ ]
28
+ }
29
+ }
30
+ ```
31
+
32
+ The examples folder contains a few sample models that you can use as reference.
8
33
9
34
10
35
## Model mapping and supported types
11
36
12
37
13
- Field Type | Java Type | Database Type
14
- ------------|-------------|----------------------------------------------
15
- text | String | text (or varchar if there is a length constraint)
16
- int | Integer | integer
17
- long | Long | bigint
18
- float | Double | double precision
19
- decimal | BigDecimal | numeric
20
- date | Date | timestamp with time zone
21
- boolean | Boolean | Boolean
22
- binary | byte[ ] | bytea
23
- json | JSONObject | jasonb
24
- geo | Object | geometry(Geometry,4326)
25
- password | String (bcrypt hash) | text (bcrypt hash)
26
-
27
-
38
+ Field Type | Java Type | Database Type | Comments
39
+ ------------|-------------|-----------------|----------------------------
40
+ int | Integer | integer |
41
+ long | Long | bigint |
42
+ float | Double | double precision |
43
+ double | Double | double precision |
44
+ decimal | BigDecimal | numeric |
45
+ numeric | BigDecimal | numeric |
46
+ text | String | text or varchar | varchar if there is a length constraint
47
+ string | String | text or varchar | varchar if there is a length constraint
48
+ char | String | char(1) |
49
+ boolean | Boolean | Boolean |
50
+ date | Date | timestamp with time zone |
51
+ binary | byte[ ] | bytea |
52
+ json | JSONObject | jasonb |
53
+ geo | Geometry | geometry(Geometry,4326) | For lat/lon geographic data
54
+ geometry | Geometry | geometry(GeometryZ) | For x,y,z data
55
+ password | String | text | Stores bcrypt hash
56
+
57
+ In addition to these standard field types, you can specify a model as a ` type ` . Example:
58
+
59
+ ``` javascript
60
+ {
61
+ Contact: {
62
+ fields: [
63
+ {name: ' name' , type: ' string' },
64
+ {name: ' address' , type: ' Address' }
65
+ ]
66
+ },
67
+ Address: {
68
+ ...
69
+ }
70
+ }
71
+ ```
28
72
29
73
30
74
## Supported field constraints
0 commit comments