Skip to content

tugrulaslan/JavaTransactionProjectsRepo

Repository files navigation

JavaTransactionProjectsRepo

This repository contains sample projects for transactions in java solutions. I've created these project to apprehend a comprehensive study the transactions in the mixture flavor of frameworks out there. All the projects are tested on; -Wildfly 10 -MySQL

If you decide to download the source code and run, before doing so, please consult the "Setup" section.

SpringTransactionProject

In this project you will find transactions in three aspects; -Programmatic Transactions(run ProgrammaticTransactionMainApp.java), -Declarative Transactions using xml(run DeclarativeTransactionXMLMainApp.java), -Declarative Transactions using annotations(run DeclarativeTransactionAnnotationMainApp.java).

HibernateTransactionProject

This is a standalone project that I've used JPA Implementation of Hibernate, entity manager is used to manage entities. In this project I've demonstrated the Programmatic Transactions only.

HibernateSpringJTAApp

In this project I am demonstating how Hibernate's Declarative JTA transactions can be handled using spring framework. This is a web application that I couldn't turn it into a standalone project which is very tricky as I saw on the internet. It required lots of configuration for a demonstation purpose, I found it unnecessary and decided to turn this into a web app. To be able to run this project, you'll need to make configurations on your Wildfly Server.

Setup

Lombok Plugin

In all of my projects, I've used lombok for boiler plate code. If you are going to run the project; -In Intellij: https://projectlombok.org/setup/intellij -In Eclipse and flavors: https://projectlombok.org/setup/eclipse

Database Setup

CREATE SCHEMA transactionproject DEFAULT CHARACTER SET utf8 ; CREATE TABLE transactionproject.employee ( id INT NOT NULL AUTO_INCREMENT, name VARCHAR(45) NULL, department VARCHAR(45) NULL, UNIQUE INDEX id_UNIQUE (id ASC), PRIMARY KEY (id));

Wildfly JTA Setup and Configuration

  1. Add a management user in wildfly,
  2. Download the mysql connector jar
  3. In the modules folder of Wildfly home, create these folders sequence: com\mysql\main
  4. Move the mysql jar here
  5. In the same folder, create a file named “module.xml” and paste content(take the name of the jar file into consideration);
  1. Open the “standalone.xml” file and in the section add the following above h2 entry;
com.mysql.jdbc.jdbc2.optional.MysqlXADataSource
  1. Go to the line and add the below line(mind the connection details) jdbc:mysql://localhost:3306/transactionproject mysql root root 127.0.0.1 transactionproject root root mysql

  2. Start the server and you will see jar loaded and the datasource is created

INFO [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-8) WFLYJCA0018: Started Driver service with driver-name = mysql INFO [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-3) WFLYJCA0001: Bound data source [java:/mysqlDataSource]

  1. Go to http://narayana.io/downloads/index.html download the NTA Binary the ear
  2. Move the ear file JBOSSHOME standalone\deployments
  3. open browser and navigate to http://localhost:8080/nta/

About

This repository contains sample projects for transactions in java solutions

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages