Oracle BPM Installation on Ubuntu : Error he “OpenJDK JVM is not supported on this platform.”

There can be a case when you try to install Oracle BPM 12.2.1.3 @ Ubuntu box and get this error message ” OpenJDK JVM is not supported on this platform.”

Launcher log file is /tmp/OraInstall2018-05-27_07-09-48PM/launcher2018-05-27_07-09-48PM.log.
Extracting the installer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Done
The OpenJDK JVM is not supported on this platform.
The log is located here: /tmp/OraInstall2018-05-27_0

 

Step 1: run java -version

openjdk version “1.8.0_131”
OpenJDK Runtime Environment (build 1.8.0_131-8u131-b11-2ubuntu1.16.04.3-b11)
OpenJDK 64-Bit Server VM (build 25.131-b11, mixed mode)

Step 2 :

sudo add-apt-repository ppa:webupd8team/java

Step 3 :
sudo apt-get update


step 4:
sudo apt-get install oracle-java8-installer


Step 5:
sudo update-alternatives --config java

 

Backward Migration of BPM Project 12c

If you are getting this error,”Unable to load the application file.Workspace .jws already migrated to newer version (12.2.1.2.0).”

This means that the version of your Application is ahead of your Jdev.

To open same app in same Jdev, open Jws file

find
”      <value n=”oracle.adf.share.dt.migration.wsm.PolicyAttachmentMigratorHelper” v=”12.1.2.0.0″/>”

and comment it

<!–      <value n=”oracle.adf.share.dt.migration.wsm.PolicyAttachmentMigratorHelper” v=”12.1.2.0.0″/>–>

similarly find
<value n=”oracle.ide.model.Project” v=”11.1.1.1.0;12.2.1.1.0″/>
change it to
<!–      <value n=”oracle.ide.model.Project” v=”11.1.1.1.0;12.2.1.1.0″/>–>

 

Mybatis : Implementation :Sample Project

Pre-Requisites: (Eclipse with Maven Plugin)

Steps:

1.Create Mybatis Enabled Project
2.Add Mybatis Maven Dependency
3.Create Mybatis Configuration
4.Create SQLSessionFactory
5.Create Sample Table in Database
6.Create Mapper XML
7.Create Results Object POJO
8.Create Mapper Interface
9.Create Service Class and Implement Mapper Interface
10.Create Junit Test case to Run Service Class

Step 1: Create MavenEnabled Project

CreateMavenProject

Step 2: Add Mybatis Depedency

 

CreateMavenProject

 

Step 3: 3.Create Mybatis Configuration

CreateMavenProject

Contents:

<?xml version=”1.0″ encoding=”UTF-8″ ?>
<!DOCTYPE configuration
PUBLIC “-//mybatis.org//DTD Config 3.0//EN”
http://mybatis.org/dtd/mybatis-3-config.dtd”&gt;
<configuration>
<typeAliases>

<typeAlias alias=”DomainClassName” type=”com.company.project.mybatis.domain.DomainClassName” />
</typeAliases>
<environments default=”development”>
<environment id=”development”>
<transactionManager type=”JDBC” />
<dataSource type=”POOLED”>
<property name=”driver” value=”com.mysql.jdbc.Driver” />
<property name=”url”
value=”jdbc:mysql://DBIP:3306/DBName” />
<property name=”username” value=”username” />
<property name=”password” value=”password” />
</dataSource>
</environment>
</environments>
<mappers>

<mapper resource=”com/makemytrip/activiti/mybatis/mappers/DomainClassNameMapper.xml” />

</mappers>
</configuration>

Step 4:;Create SQLSessionFactory

package com.mybatis3.utils;

import java.io.*;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.*;

public class MyBatisSqlSessionFactory {
 private static SqlSessionFactory sqlSessionFactory;

public static SqlSessionFactory getSqlSessionFactory() {
 if (sqlSessionFactory == null) {
 InputStream inputStream;
 try {
 inputStream = Resources.getResourceAsStream("mybatis-config.xml");
 
 sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream);
 } catch (IOException e) {
 e.printStackTrace();
 throw new RuntimeException(e.getCause());
  }
 }
 return sqlSessionFactory;
 }

public static SqlSession openSession() {
 try{
 
 }
 catch(Exception e)
 {
 e.printStackTrace();
 
 }
 return getSqlSessionFactory().openSession();
 }
}





5.Create Sample Table in Database

CREATE TABLE `SAMPLE_DEMO_TABLE` (

  `EMPLOYEE_ID` int(11) DEFAULT NULL,

  `EMPLOYEE_NAME` varchar(200) DEFAULT NULL,

  `JOINING_DATE` date DEFAULT NULL

) ENGINE=MyISAM DEFAULT CHARSET=latin1;

 

Step 6:.Create Mapper XML

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.company.domain.dao.TestMapper">
 <resultMap id="BaseResultMap" type="com.company.domain.model.Test">
 <!--
 WARNING - @mbggenerated
 This element is automatically generated by MyBatis Generator, do not modify.
 This element was generated on Mon Aug 01 20:31:39 IST 2016.
 -->
 <result column="queries" jdbcType="VARCHAR" property="queries" />
 </resultMap>
 <sql id="Example_Where_Clause">
 <!--
 WARNING - @mbggenerated
 This element is automatically generated by MyBatis Generator, do not modify.
 This element was generated on Mon Aug 01 20:31:39 IST 2016.
 -->
 <where>
 <foreach collection="oredCriteria" item="criteria" separator="or">
 <if test="criteria.valid">
 <trim prefix="(" prefixOverrides="and" suffix=")">
 <foreach collection="criteria.criteria" item="criterion">
 <choose>
 <when test="criterion.noValue">
 and ${criterion.condition}
 </when>
 <when test="criterion.singleValue">
 and ${criterion.condition} #{criterion.value}
 </when>
 <when test="criterion.betweenValue">
 and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
 </when>
 <when test="criterion.listValue">
 and ${criterion.condition}
 <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
 #{listItem}
 </foreach>
 </when>
 </choose>
 </foreach>
 </trim>
 </if>
 </foreach>
 </where>
 </sql>
 <sql id="Update_By_Example_Where_Clause">
 <!--
 WARNING - @mbggenerated
 This element is automatically generated by MyBatis Generator, do not modify.
 This element was generated on Mon Aug 01 20:31:39 IST 2016.
 -->
 <where>
 <foreach collection="example.oredCriteria" item="criteria" separator="or">
 <if test="criteria.valid">
 <trim prefix="(" prefixOverrides="and" suffix=")">
 <foreach collection="criteria.criteria" item="criterion">
 <choose>
 <when test="criterion.noValue">
 and ${criterion.condition}
 </when>
 <when test="criterion.singleValue">
 and ${criterion.condition} #{criterion.value}
 </when>
 <when test="criterion.betweenValue">
 and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
 </when>
 <when test="criterion.listValue">
 and ${criterion.condition}
 <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
 #{listItem}
 </foreach>
 </when>
 </choose>
 </foreach>
 </trim>
 </if>
 </foreach>
 </where>
 </sql>
 <sql id="Base_Column_List">
 <!--
 WARNING - @mbggenerated
 This element is automatically generated by MyBatis Generator, do not modify.
 This element was generated on Mon Aug 01 20:31:39 IST 2016.
 -->
 queries
 </sql>
 <select id="selectByExample" parameterType="com.makemytrip.mybatisApi.model.TestExample" resultMap="BaseResultMap">
 <!--
 WARNING - @mbggenerated
 This element is automatically generated by MyBatis Generator, do not modify.
 This element was generated on Mon Aug 01 20:31:39 IST 2016.
 -->
 select
 <if test="distinct">
 distinct
 </if>
 <include refid="Base_Column_List" />
 from public.test
 <if test="_parameter != null">
 <include refid="Example_Where_Clause" />
 </if>
 <if test="orderByClause != null">
 order by ${orderByClause}
 </if>
 </select>
 <delete id="deleteByExample" parameterType="com.makemytrip.mybatisApi.model.TestExample">
 <!--
 WARNING - @mbggenerated
 This element is automatically generated by MyBatis Generator, do not modify.
 This element was generated on Mon Aug 01 20:31:39 IST 2016.
 -->
 delete from public.test
 <if test="_parameter != null">
 <include refid="Example_Where_Clause" />
 </if>
 </delete>
 <insert id="insert" parameterType="com.makemytrip.mybatisApi.model.Test">
 <!--
 WARNING - @mbggenerated
 This element is automatically generated by MyBatis Generator, do not modify.
 This element was generated on Mon Aug 01 20:31:39 IST 2016.
 -->
 insert into public.test (queries)
 values (#{queries,jdbcType=VARCHAR})
 </insert>
 <insert id="insertSelective" parameterType="com.makemytrip.mybatisApi.model.Test">
 <!--
 WARNING - @mbggenerated
 This element is automatically generated by MyBatis Generator, do not modify.
 This element was generated on Mon Aug 01 20:31:39 IST 2016.
 -->
 insert into public.test
 <trim prefix="(" suffix=")" suffixOverrides=",">
 <if test="queries != null">
 queries,
 </if>
 </trim>
 <trim prefix="values (" suffix=")" suffixOverrides=",">
 <if test="queries != null">
 #{queries,jdbcType=VARCHAR},
 </if>
 </trim>
 </insert>
 <select id="countByExample" parameterType="com.makemytrip.mybatisApi.model.TestExample" resultType="java.lang.Integer">
 <!--
 WARNING - @mbggenerated
 This element is automatically generated by MyBatis Generator, do not modify.
 This element was generated on Mon Aug 01 20:31:39 IST 2016.
 -->
 select count(*) from public.test
 <if test="_parameter != null">
 <include refid="Example_Where_Clause" />
 </if>
 </select>
 <update id="updateByExampleSelective" parameterType="map">
 <!--
 WARNING - @mbggenerated
 This element is automatically generated by MyBatis Generator, do not modify.
 This element was generated on Mon Aug 01 20:31:39 IST 2016.
 -->
 update public.test
 <set>
 <if test="record.queries != null">
 queries = #{record.queries,jdbcType=VARCHAR},
 </if>
 </set>
 <if test="_parameter != null">
 <include refid="Update_By_Example_Where_Clause" />
 </if>
 </update>
 <update id="updateByExample" parameterType="map">
 <!--
 WARNING - @mbggenerated
 This element is automatically generated by MyBatis Generator, do not modify.
 This element was generated on Mon Aug 01 20:31:39 IST 2016.
 -->
 update public.test
 set queries = #{record.queries,jdbcType=VARCHAR}
 <if test="_parameter != null">
 <include refid="Update_By_Example_Where_Clause" />
 </if>
 </update>
</mapper>

Step 7:Create Results Object POJO

 

–> Create a POJO for Response

Step :8.Create Mapper Interface
Step :9.Create Service Class and Implement Mapper Interface
Step 10.Create Junit Test case to Run Service Class

 

 

Mybatis ( Basics , Comparison, Features)

 

 

What is Mybatis

  • Mybatis is a Persistence Framework which acts as a mediator between Application layer and Database
  • In Java applications, the persistence layer involves populating Java objects with data loaded from the database using SQL queries, and persisting the data in Java objects into the database using SQL.
  • Most of the Traditional ORMs (Ex. Hibernate) map Java Objects to Database tables, Mybatis maps Java Methods to SQL Statements.
  • MyBatis couples objects with stored procedures or SQL statements using a XML descriptor

Benefits of Mybatis

  • Light Weight…Only one JAR or Maven – Dependency Entry needed in Project
  • ResultMap:Most Powerfull feature of Mybatis
  • Dynamic SQL
o If
o choose (when, otherwise)
o trim (where, set)

for Each

  • Transaction Manager
  • JDBC : tranditional JDBC Transactions
  • Managed : J2EE Container Managed

Mybatis over JDBC

  • Eliminates Lot of Common JDBC code
  • ·Eliminates Responsibility of transaction management from hands of Programmers
  • Using ResultMap, any complex ResultSet can be converted to Object ·
  • Supports Dynamic SQL which would have been done through String concatenation or If/Else in JDBC ·
  • Uses PREPARED statement as Default ·Local Cache supports cache management at transaction level ·Transaction Management using Mybatis-Spring

 Mybatis over Hibernate

 

Point MyBatis Hibernate
Size Lightweight Comparatively larger in Size
Learning Curve Low Learning Curve Higher Learning Curve
Programming Uses SQL, so is DB Programming Uses HQL, Independent of DB, Easy to
Return Type Maps ResultSet from JDBC API to POJO Maps Java Objects to Database Tables
USPs More Fetch Centric More Persistence Centric
Table Vs POJO Mapping No orm impedance mismatch, until required , Result map doesn’t need to be refreshed Tightly coupled, Ex. any column in table needs to updated in POJO immediately

Caching

MyBatis has inbuilt support for caching SELECT query results within the scope of SqlSession level ResultSets. In addition to this, MyBatis also provides integration support for various third-partycache libraries, such as EHCache, OSCache,and Hazelcast.

MyBatis has two layers of caching:

Local Cache Local Cache is always enabled.

It has two Scopes , Session and Statement where Session is default.It is actually a MAP which contains below Key and Value.

key = (mybatis-namespace + stmt-name) + (raw sql including parameter placeholders) + (actual SQL parameter values)

value = (list of Java objects resulting from that query)

When localCacheScope=STATEMENT then the cache is cleared at the end of each MyBatis statement.

When localCacheScope=SESSION, then the cache is cleared:

  • at the end of the current transaction (or end of each statement when autoCommit=true)
  • whenever any insert/update/delete statement is executed

Second Level Cache

  • Shares data between transactions
  • By default, returns a copy of the cached object created via serialize/deserialize – which requires all cacheable objects to implement Serializable
  • Can hook into “enterprise” caching systems, or use a simple in-memory cache. Thein-memory approach works only when the DB is exclusively updated by a single process

By default, flushes the entire cache whenever an <insert>, <update> or <delete> MyBatis statement is executed.

Keys cache entries by the same key for the local cache, ie a string built from (mybatis- namespace + stmt-name) + (raw sql) + (actual parameter values)

Conclusion

Local Cache stores data till duration of transaction, hence it is good.However it wont be much helpful with optimizing read-only or master data.For optimization, Second level cache should be used.

Transaction Management with Mybatis-Spring

It uses existing DataSourceTransactionManager from Spring.

It can be used using Spring’s @Transactional annotation.

Container Managed Transactions

Leave Responsibility of transaction management with J2EE Container

Programatic Transaction Management

Spring will handle your transaction (Sample code below, how to handle transactin)

DefaultTransactionDefinition def = new DefaultTransactionDefinition(); def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED); TransactionStatus status = txManager.getTransaction(def);

try { userMapper.insertUser(user);

// Inserting into table using Mybatis Mapper

}

catch (MyException ex) { txManager.rollback(status); throw ex;