Maj_ORM An Object Relational Mapper for Java

A object relational Mapper, store whole java objects in a database, providing an easy mechanism to access Java Bean/Objects/Entities and populate a database.

Maj ORM also contains the logic to produce multiple database connections to both, MySQL, MS SQL and Cassandra, databases. Later we plan to offer automatic backup, failover and production of database schema in an additional premium package.

Current Version, 1.1 - Early Release

Usage: Add MajDbORM-(version).jar to classname or maven or gradle libs The Database ORM system is first loaded by com.majorana.ORM.DbBean.getSingletonLazy() Which may be called as often as you like, but will only produces a single instance. The ORM start up will read from the environment variables for the OS running the JVM, and try to connected to databases with the following structure to the Variables. Majorana_dbname_credname with as name dbname as you wish

The Database Credentials.

M
Type & NameDescription
NameName of the Datasource
DatabaseVariant variantOne of MySQL, MSSQL, Cassanadra (cass insensitive)
String hostAddressIP Address of Database v4/v6
int portPort of Database connection
String usernameUsername for Database connection
String passwdPassword for Database connection
String remoteDatabaseNameAtServiceName of Database Schema on the database connection
int priorityLowest number is highest priority and becames the name database connection
String groupDatabase Group (Used by Cassandra)
boolean useSSL if true use an SSL connection for the database
boolean verifySSLCertif true verify the SSL Cert for the connection
String isolationLevel For ACID databases the isolationLevel - what to do about simultaneous updates on the same table
boolean allowPublicKeyRetrievalAllow MajDbORM to retrieve public keys remotely for connections
String poolNameName of Pool of Database connections (Zaxxa, MySQL, Ms SQL)
minimumIdleTimeoutClose db connection if idea of more than this many secods
maxPoolSizeNumber of (Zaxxa) Maximum Database connections held open at a time
minimumIdleConMinimum number of idea database connections (only this pool) to hold open at a time
connectionTimeout Close connection this many miliseconds

Entity Annotations

Many of the Jakarta/Javax persistance Annotations available as well as extra com.majorana.persist.annot ones Any Entity to be persisted should extends com.majorana.ORM.MajoranaBaseEntity Fields marked with @Column will be persisted to and from the database, But static or transient fields will never be persisted Store the current timestamp when the entity is updatedStore the curremt timestamp when the entity is first createdM
Annotation on TypeFrom LibraryParametersDescription
Column - for FieldsJakarta/JavaxNameName of Database column
Id - for fieldsJakarta/JaxaxN/AIndicate column is a primary key
DirEntityVersion - One class in packageMajoranaint major, int minorVersioning number for a package or directory, only if the Env Vars DBVersion.major DBVersion.minor are greater or equal to these will the case be automatically loaded
Nullable - FieldMajoranaN/AIndicated the column may be null
Presave - MethodMajoranaN/AIndicates a method to run in the Entity before saving to the DB
Postload - MethodMajoranaN/AIndicates a method to run in the Entity after retriving from the DB
UpdateableMajoranaN/AIndicate a field should be updated by a CRUD update
PopulatedUpdated - LocalDateTime fieldMajoranaN/A
PopulatedCreated - LocalDateTime fieldMajoranaN/A

Crud Usage

DbBean dbb = DbBean.getSingletonLazy(); dbb.connect(); YourEntityClass en = new YourEntityClass(); MultiId id = dbb.store(en); int sqlId = id.getId(); UUID cassId = id.getUUID(); en.setField("New Date"); dbb.update(id, en); // or YourEntityClass en1 = dbb.getBean(YourEntityClass.class, new String[]{"idfield"}, new Integer[]{sqlId} dbb.deleteBeanById(id, en1);

ORM Usage

DbBean dbb = DbBean.getSingletonLazy(); dbb.connect(); YourEntityClass en = new YourEntityClass(); MajoranaAnnotationRepository mar = dbb.getRepo(YourEntityClass.class); en = mar.setRandom( mar.repoFields, en, new java.util.Random(); MultId id = storeBean(id); YourEntityClass en1= mar.setRandom( mar.repoFields, en, new java.util.Random(); int ch = dbb.updateSQL( mar.getUpdateString, en1.getParams(en1)); YourEntityClass en2 = mar.getBean(YourEntityClass.class, "SELECT "+mar.getReadString(), new String[]{ "field1","field2"}, new Object[]{ en2.getField1(), en2.getField2() }; int ch1 = dbb.deleteBeans(YourEntityClass.class, new String[]{ "id"}, new Integer[]{id};