Note: This file is written in Markdown and is best viewed with a Markdown viewer (e.g., GitHub, GitLab, VS Code, or a dedicated Markdown reader). Viewing it in a plain text editor may not render the formatting as intended.
Copyright (c) 2026 Software Tree
This project demonstrates simple CRUD (Create, Read, Update, Delete) operations on objects of a basic domain model class using the JDX ORM (Object Relational Mapping) library. It shows how JDX ORM API calls can transparently exchange Java object data with a relational database without manual SQL.
The example application creates, queries, updates, and deletes instances of ClassA — a simple model class with fields of several common Java types (int, String, Date, boolean, float).
- Java JDK 8 or higher installed and on the system PATH.
- JDX ORM SDK installed. Set the environment variable
JX_HOMEto the SDK's top-level installation directory. - A supported JDBC-compatible database (SQLite is pre-configured; MySQL and PostgreSQL examples are also included in the
.jdxfile).
JDX_SimpleExample/
├── config/
│ └── simple_example.jdx # ORM mapping specification file
├── src/
│ └── com/softwaretree/jdxsimpleexample/
│ ├── SimpleExample.java # Main application entry point
│ └── model/
│ └── ClassA.java # Domain model class
├── bin/ # Compiled .class files (generated)
├── sources.txt # List of Java source files for compilation
├── compile.cmd # Windows: compile the Java source files
├── compile.sh # Mac/Linux: compile the Java source files
├── setEnvironment.bat # Windows: sets classpath environment variable
├── setEnvironment.sh # Mac/Linux: sets classpath environment variable
├── runJDXExample.bat # Windows: run the sample application
├── runJDXExample.sh # Mac/Linux: run the sample application
├── forward.bat # Windows: create/recreate the database schema
├── forward.sh # Mac/Linux: create/recreate the database schema
├── JDXDemo.bat # Windows: launch the JDXDemo GUI application
├── JDXDemo.sh # Mac/Linux: launch the JDXDemo GUI application
└── README.md # This file
This declarative file tells JDX ORM how to map Java classes to database tables. It specifies:
JDX_DATABASE— the JDBC connection URL, credentials, database type, and debug level.JDBC_DRIVER— the JDBC driver class name.CLASS/PRIMARY_KEY— the Java class(es) to be managed and their primary key field(s).
The file comes pre-configured for SQLite (no additional database setup required). Commented-out examples for MySQL and PostgreSQL are also included. Refer to the JDX Database & JDBC Driver Specification Guide for details on configuring other databases.
Note: Update
JDX_DATABASEandJDBC_DRIVERto match your local database setup before running.
A simple POJO (Plain Old Java Object) that JDX ORM maps to a database table. It has the following fields:
| Field | Type | Description |
|---|---|---|
aId |
int |
Primary key |
aString |
String |
A text field |
aDate |
Date |
A date field |
aBoolean |
boolean |
A boolean flag |
aFloat |
float |
A floating-point value |
A no-arg default constructor is included as required by JDX ORM for object instantiation.
The entry point of the sample application. It:
- Initializes JDX ORM using the
.jdxmapping file. - Optionally creates the database schema automatically.
- Runs a sequence of CRUD operations via
JDXHelper:- Delete all existing
ClassArecords. - Insert three new
ClassAobjects (A1,A2,A3). - Query all objects; query with ordering; query with filter conditions.
- Update a specific object and re-query it.
- Delete a specific object and query the remaining records.
- Delete all existing
- Cleans up the JDX ORM connection on exit.
A plain-text file listing all .java source files to be compiled, one per line, in the format:
./src/com/softwaretree/jdxsimpleexample/model/ClassA.java
./src/com/softwaretree/jdxsimpleexample/SimpleExample.java
This file is passed to javac using the @sources.txt argument syntax.
Compiles all Java source files listed in sources.txt and outputs .class files into the bin/ directory.
- Requires
JX_HOMEto be set to the JDX ORM SDK installation directory. - Links against
jxclasses.jar(JDX ORM library) andjson-20240303.jar(JSON support). compile.cmd— Windows batch script (supports JDK 8; a commented line supports JDK 9+).compile.sh— Mac/Linux shell script equivalent.
Windows:
compile.cmdMac/Linux:
chmod +x compile.sh # first time only
./compile.shSets the CLASSPATH environment variable to include the JDX ORM libraries and the appropriate JDBC driver JAR for your database. Edit this file to point to the correct JDBC driver for your database before running the application.
setEnvironment.bat— Windows (uses;as classpath separator)setEnvironment.sh— Mac/Linux (uses:as classpath separator; sourced viasource ./setEnvironment.sh)
Invokes the environment setup script to configure the classpath, then runs the SimpleExample main class.
Windows:
runJDXExample.batMac/Linux:
chmod +x runJDXExample.sh # first time only
./runJDXExample.shCreates (or recreates) the database schema based on the ORM specification in the .jdx file, without running the application.
Windows:
forward -createMac/Linux:
chmod +x forward.sh # first time only
./forward.sh -createLaunches the JDXDemo desktop GUI application, which provides a graphical way to browse and interact with the database using the JDX ORM configuration.
Windows:
JDXDemo.batMac/Linux:
chmod +x JDXDemo.sh # first time only
./JDXDemo.sh-
Set
JX_HOMEto the root of your JDX ORM SDK installation. -
Configure the database by editing
config/simple_example.jdx:- Update
JDX_DATABASEwith the correct connection URL and credentials. - Update
JDBC_DRIVERwith the appropriate JDBC driver class. - Update
setEnvironment.bat(Windows) orsetEnvironment.sh(Mac/Linux) to include the JDBC driver JAR on the classpath.
- Update
-
Compile the source files:
compile.cmd # Windows ./compile.sh # Mac/Linux
-
Run the sample application:
runJDXExample.bat # Windows ./runJDXExample.sh # Mac/Linux
The application will automatically create the database schema on first run (controlled by the
forceCreateSchemaflag inSimpleExample.java).
Mac/Linux tip: Run
chmod +x *.shonce in the project directory to make all shell scripts executable.
This project can be imported directly into the Eclipse IDE as an existing Java project using File → Import → Existing Projects into Workspace.
- JDX Database & JDBC Driver Specification Guide
- JDX ORM SDK documentation (included in your SDK installation under
JX_HOME)