J-Framework Data

The data API is a component of the smart-cloud framework. It makes the development of database driven applications in Java more convenient and efficient.

Main features:

  1. Unified configuration file

  2. Auto synchronization for database in case of JPA entities (thanks to Hibernate)

  3. Elegant and simple API (proven to work with minimum Java experience)

  4. Single API to communicate with databases with both: JDBC (SQL inside Java) and JPA (No SQL, just Java classes with mapping to database).

  5. Convention for keeping SQL queries inside external files, perfectly makes send to.

  6. Built in caching mechanism.

  7. Built in connection pooling.

Configurations:

The framework run on local file based H2 database by default, so basically no configuration needed. This could be good idea for test automation, proof-of-concepts, or trying things out. However, for real-life applications, you will need to control the configurations.

To manage the configuration of your database(s), please refer to the Config Guide.

Maven dependency:

{framework-version}

<dependency>
	<groupId>com.jalalkiswani</groupId>
	<artifactId>j-framework-data</artifactId>
	<version>6.0.0</version>
</dependency>

Basic JDBC Example:

1- src/main/resources/config.properties

Unresolved include directive in modules/6.x.x/pages/frameworks/jk-framework/jk-framework-data/reference.adoc - include::source/src/main/resources/config.properties[]

2- src/main/java/com/jk/example/jdbc/Account.java

Unresolved include directive in modules/6.x.x/pages/frameworks/jk-framework/jk-framework-data/reference.adoc - include::source/src/main/java/com/jk/example/jdbc/Account.java[]

3- src/main/java/com/jk/example/jdbc/Account2.java

Unresolved include directive in modules/6.x.x/pages/frameworks/jk-framework/jk-framework-data/reference.adoc - include::source/src/main/java/com/jk/example/jdbc/Account2.java[]

4- src/main/java/com/jk/example/jdbc/JdbcBasicExample.java

Unresolved include directive in modules/6.x.x/pages/frameworks/jk-framework/jk-framework-data/reference.adoc - include::source/src/main/java/com/jk/example/jdbc/JdbcBasicExample.java[]

Basic JPA Example:

1- src/main/java/com/jk/example/jpa/Student.java

Unresolved include directive in modules/6.x.x/pages/frameworks/jk-framework/jk-framework-data/reference.adoc - include::source/src/main/java/com/jk/example/jpa/Student.java[]

2- src/main/java/com/jk/example/jpa/JPATest.java

Unresolved include directive in modules/6.x.x/pages/frameworks/jk-framework/jk-framework-data/reference.adoc - include::source/src/main/java/com/jk/example/jpa/JPATest.java[]

Naming Strategy

By default the framework will map to database tables according to the following rules: 1. Convert the camel-case names to snake-case (underscores) 2. Lowercase the names

In case of Oracle: 1. All the names will be converted to upper case 2. Any field with reserved keyword name will be post-fixed with underscore, for exampe a field with uid name will be map to a column with name UID_

Default Configuration

Below are the default configurations, which are set in the default.config.porperties in the framework

Unresolved include directive in modules/6.x.x/pages/frameworks/jk-framework/jk-framework-data/reference.adoc - include::source/default.config.properties[]