Spring Batch Example Reading/Write from Database to File and File to Database

In this Article you will learn how to read date from data base to csv or xml file an xml file to Database using Spring batch. it is very simple example we are using my sql data base and csv and xml files Pre Requisites: 1.Java 1.7 2. Spring 3.Maven 4. MySQL Pom.xml

2.  […]

How to Remove Duplicate From Array

How to Remove Duplicate from Array using Java

OutPut:

 

Spring Boot Hello World Example

In this Article, you will learn how to setup and start first Spring boot Example. we are using here annotations for creating a simple application. below are prerequisites you need to setup spring boot application in your local. 1.Java 1.7 2.Eclipse OxyGen 3.Spring 4.Maven Below is the Pom.xml 1. we need below dependencies to have […]

Java String to Int example

In this tutorial we see how to convert string to int. Generally when we enter int values in text filed, text area and submit the form, the parameters we will receive like as a string format in server side. In that case we need to convert those values in int format and perform the operations. […]

Exception in thread “main” java.lang.IllegalStateException: CGLIB is required to process @Configuration classes

During developing Spring applications we might get below exception, basically we might get this exception when we are using “@Configuration” annotation in our Application and we are not adding the “cglib-nodep”  jar in to class path.   Mar 11, 2015 3:59:36 PM org.springframework.context.support.AbstractApplicationContext prepareRefresh INFO: Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@1d8c528: startup date [Wed Mar 11 15:59:36 IST 2015]; root […]

spring javaconfig example – @Configuration

In this tutorial we are going to explore how we can achieve to build a completely XML-free sample Spring  application. Before Spring 3.0  we are using XML based approach to configure our beans in xml file. But in Spring 3.0 we have new feature “@Configuration”  which is useful to configure our beans in programmatically. let us have […]

Generator classes in Hibernate

Generator classes are used to generate the ‘identifier or primary key value‘ for a persistent object while saving an object in database. Hibernate provides different primary key generator algorithms. All hibernate generator classes implements hibernate.id.IdentifierGenerator interface, and overrides the generate(SessionImplementor,Object) method to generate the ‘identifier or primary key value‘. If we want our own user […]

persist() and replicate() methods in Hibernate

persist(): 

It is equivalent to save(object) , but save(object) method returns identifier and persist(object) returns nothing. Use save() method, If you are using generator class to generate the identifier and you want to know the identifier value. Use persist() method, if you don’t want to know the generated identifier. replicate(): Use to move the […]

getTransaction(),beginTransaction(),getIdentifier() in Hibernate

Transaction object can be created by 2 ways

getTransaction(): Returns the Transaction object associated with current session. It returns the same Transaction object for every request.

We need to call begin() method on Transaction object to start the transaction.

beginTransaction(): Returns different transaction objects. For each and every request transaction object creates a~lcl begins new transaction context.

getIdentifier(): Use to […]

merge() method in Hibernate

merge(): It merge the detached object data into persistent data.

Lets understand merge() method by example. Employee table in database

 

Output in Eclipse

Employee table in database,After execution of above program  

Before 23rd line, emp1 is in Persistent state and emp2 is in detached state. In 23rd line, merge() method […]