JsonRecordSeparatorPolicy example

In this post under Spring Batch, I will explain the purpose and how to use JsonRecordSeparatorPolicy class with an example. JsonRecordSeparatorPolicy class is a concrete implementation of org.springframework.batch.item.file.separator.RecordSeparatorPolicy interface. In one of my previous post I have explained the purpose of RecordSeparatorPolicy and how to use it. For recap, RecordSeparatorPolicy interface is used to tell…… Continue reading JsonRecordSeparatorPolicy example

Deleting a persisted object

In this post under hibrenate, I will explain how to delete a persisted object. We can delete a persisted object using Session interface delete method. Below is the complete code Main Class 1 import org.hibernate.Session; 2 import org.hibernate.SessionFactory; 3 4 public class HibernateDemo9 { 5 public static void main(String[] args) { 6 SessionFactory sessionFactory =…… Continue reading Deleting a persisted object

Custom Error Handling when parsing xml through SAX api

In this post under JAXP, I will explain how to add custom error handler when parsing xml document through SAX api. To provie a custom error handler, we need to implement the interface org.xml.sax.ErrorHandler as shown below package sax; import org.xml.sax.ErrorHandler; import org.xml.sax.SAXException; import org.xml.sax.SAXParseException; public class CustomErrorHandler implements ErrorHandler { @Override public void error(SAXParseException…… Continue reading Custom Error Handling when parsing xml through SAX api

Java Util Logging ErrorManager example

In this post under java logging, I will explain the purpose of ErrorManager and how we can use it. Whenever we write the below code logger.info(“Hello my name is Sumanth1”); We are requesting the Handler to log the message to a destination. What if an error happens at the Handler level when an attempt is…… Continue reading Java Util Logging ErrorManager example

JsonLineMapper Example

In this post under Spring Batch, I will explain the purpose of JsonLineMapper with an example. JsonLineMapper is used with reader bean for reading file containing JSON input as shown below JsonFileInput.txt {“id”:”id0″,”name”:”name0″,”status”:”status0″,”salary”:0}{“id”:”id1″,”name”:”name1″,”status”:”status1″,”salary”:1}{“id”:”id2″,”name”:”name2″,”status”:”status2″,”salary”:2}{“id”:”id3″,”name”:”name3″,”status”:”status3″,”salary”:3}{“id”:”id4″,”name”:”name4″,”status”:”status4″,”salary”:4}{“id”:”id5″,”name”:”name5″,”status”:”status5″,”salary”:5}{“id”:”id6″,”name”:”name6″,”status”:”status6″,”salary”:6}{“id”:”id7″,”name”:”name7″,”status”:”status7″,”salary”:7}{“id”:”id8″,”name”:”name8″,”status”:”status8″,”salary”:8}{“id”:”id9″,”name”:”name9″,”status”:”status9″,”salary”:9} Each line in the file is interpreted as a JSON object by JsonLineMapper. So each line must start with “{” and end…… Continue reading JsonLineMapper Example