JavaXT
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Object Relational MappingThe javaxt-orm library is a handy tool for generating Java code and DDL from a set of models defined in a Javascript or JSON document. The generated classes are used to persist data in a relational database via the javaxt.sql.Model class. Download javaxt-orm
Current Version: 1.1.0
Release Date: 5/21/2023 File Size: 36 KB File Format: Zip Includes: Jar File, Binaries, Source Code, and Documentation Key Features
Note that this is not intended to be a full fledged ORM framework. Instead, the goal is to help jumpstart new projects by providing a simple utility for stubbing out code and SQL. Basic UsageThe javaxt-orm library provides a command line interface that can be used to generate Java classes and schema. All you need to do is provide a input model and an output directory. Example: java -jar javaxt-orm.jar /path/to/model.js /output Model InputBelow is a simple example of an input Javascript file with an Address model.var package = "com.example.models"; var models = { Address: { fields: [ {name: 'street', type: 'string'}, {name: 'city', type: 'string'}, {name: 'state', type: 'string'}, {name: 'postalCode', type: 'string'}, {name: 'coordinates', type: 'geo'} ] } } The full list of field types are listed below. In addition to the standard field types, you can specify a model as a `type`. In the example below, the address field in the Contact model is a `Address` type. { Contact: { fields: [ {name: 'name', type: 'string'}, {name: 'address', type: 'Address'} ] }, Address: { ... } } Model mapping and supported types
Notes:
Supported field constraints
The following is an example of a "User" model with constraints defined for several fields (e.g. username, password, active): { User: { fields: [ {name: 'username', type: 'string'}, {name: 'password', type: 'password'}, {name: 'accessLevel', type: 'int'}, {name: 'active', type: 'boolean'}, {name: 'contact', type: 'Contact'}, {name: 'auth', type: 'json'} ], constraints: [ {name: 'username', required: true, length: 255, unique: true}, {name: 'password', required: true}, {name: 'active', required: true} ], defaults: [ {name: 'active', value: true} ] } } DependenciesThe javaxt-orm library is compiled using Java 11 requires the following libraries:
Generated Code DependenciesThe javaxt-orm library generates Java code that extends/implements javaxt.sql.Model class. It also calls java.util.Map.ofEntries which was introduced in Java 9. Therefore, you will need both javaxt-core and Java 9 (or higher) to use the generated code in your project. In addition, you will need JTS if you include a `geo` or `geometry` type. Last but not least, you will need to include a JDBC driver in your project for persistance.LicenseAll JavaXT libraries are free and open source released under a permissive MIT license. This software comes with no guarantees or warranties. You may use this software in any open source or commercial project.Maven SupportIf you're a Maven user, you can configure your pom.xml to pull releases directly from this site. To add javaxt-orm to your project, simply add this site to your list of repositories and add a dependency. XML snippits below. See the downloads page for more information.Add Maven Repository
<repositories> <repository> <id>javaxt.com</id> <url>https://www.javaxt.com/maven</url> </repository> </repositories> Add Maven Dependency
<dependencies> <dependency> <groupId>javaxt</groupId> <artifactId>javaxt-orm</artifactId> <version>1.1.0</version> </dependency> </dependencies> |