Month: October 2015

How to develop multi modules Project in Maven

Posted on Updated on

maven

 

 

A multi modules project consists a set of modules where each module works / configures as a project to logical group of sub-project that work together to build a complete project. As usually a large or complex project containing multiple modules in which individual or a team work together to accomplish the goal of software development.

Typically, a root or parent pom.xml file to be configured all sub-modules in such a way that during the maven build, it provide a complete packaging (JAR,WAR,EAR) in target folder even if it could be packaged in form of ZIP or GZIP format in your target folder. During this section we will demonstrate how to configure it.

There are many way to configure maven project either using IDE or manually but we did it manually by creating project folder then set-up pom.xml file inside build folder and other related sub-modules inside project folder, finally import it with IDE ( Eclipse ) by maven project.

In this section, we created three sub-modules project receptively :-

  • interface :  interface module contain resource bundles and web folder ( ideally it represent a web project containing all jsp/html/js/xml as well as web.xml file)
  • web :  web module contain all action file, helper  and resources bundles.
  • service :  Service module contain all business logic including DAO, Bean, Service and Component class and their implementation.

build :  This folder contains only parent pom.xml, in order to build project navigate inside this folder using command and then run following command:-

  • mvn eclipse:clean eclipse:eclipse” ( generate classpath with all dependencies )
  • followed by “mvn clean install” ( clean target folder and compile, build and packaging project in form of JAR,WAR or EAR )

Maven Project hierarchy in Eclipse maven import:-

 

 

 

 

 

 

Project hierarchy in Eclipse :-

pom-project-h2

 

Parent root pom.xml under build folder:-

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

<groupId>com.search.job</groupId>
<artifactId>build</artifactId>
<modelVersion>4.0.0</modelVersion>
<packaging>pom</packaging>
<name>Build</name>
<version>1.0-SNAPSHOT</version>
<description>
Root Project For Search Job
</description>

<!--Core Modules-->
<modules>
<module>../service</module>
<module>../web</module>
<module>../interface</module>
</modules>


<!-- Build Configration Settings -->
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>

<properties>
<version.activiti>5.14</version.activiti>

<version.commons-io>1.3.2</version.commons-io>
<version.commons.configuration>1.6</version.commons.configuration>
 ....
 ....
</properties>
</project>

Service Pom.xml file :-


<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
 <parent>
 <artifactId>build</artifactId>
 <groupId>com.search.job</groupId>
 <version>1.0-SNAPSHOT</version>
 <relativePath>../build/pom.xml</relativePath>
 </parent>
 <modelVersion>4.0.0</modelVersion>
 <artifactId>service</artifactId>
 <name>service</name>
 <packaging>jar</packaging>
 <dependencies>
  <!-- maven dependencies -->
 <dependency>
  
</dependency>

 </dependencies>
</project>

Web Project pom.xml:


<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<artifactId>build</artifactId>
<groupId>com.search.job</groupId>
<version>1.0-SNAPSHOT</version>
<relativePath>../build/pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>web</artifactId>
<name>web</name>
<packaging>jar</packaging>
<dependencies>
 <!-- maven dependencies -->
<dependency>

</dependency>
</dependencies>
</project>

Interface Project pom.xml

 

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

<parent>
<artifactId>build</artifactId>
<groupId>com.search.job</groupId>
<version>1.0-SNAPSHOT</version>
<relativePath>../build/pom.xml</relativePath>
</parent>

<modelVersion>4.0.0</modelVersion>
<artifactId>interface</artifactId>
<name>Search Job INterface</name>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>

<dependencies>

 <!-- maven dependencies -->
<dependency>

</dependency>

</dependencies>

<build>
<!-- Final package (JAR,WAR,EAR ) name to be SearchJob -->
<finalName>SearchJob</finalName>
</build>
</project>

SQL Interview Question

Posted on Updated on

MySQL

 

 

 

Concatenate multiple row into a single row :

GROUP_CONCAT(expr)

This function returns a string result with the concatenated non-NULL values from a group. It returns NULL if there are no non-NULL values. The full syntax is as follows:

GROUP_CONCAT([DISTINCT] expr [,expr …] [ORDER BY {unsigned_integer | col_name | expr} [ASC | DESC] [,col_name …]] [SEPARATOR str_val])

mysql>SELECT NAME, reminder_date,STATUS FROM enquiry;

single-row-2

 

 

 

 

 

 


mysql>SELECT id, NAME,GROUP_CONCAT(DISTINCT STATUS ORDER BY reminder_date DESC SEPARATOR ‘,’)AS STATUS FROM enquiry GROUP BY NAME

single-row

 

 Find nth largest Salary in Employee Table:-

Select all Employee rows by Salary descending order.

 mysql>SELECT * FROM employee ORDER BY salary DESC;

employee-table

 

 

 

 

Fetch 4th largest salary holder Employee :-

syntax : 

select * from <table-name> t2 where ( n-1 ) = ( select count(distinct(<t2>.<column-name>)) from <table-name> t2 where t2.salary > t1.salary);

example :-

         mysql>SELECT * FROM employee e1
WHERE  (4-1) = ( SELECT COUNT(DISTINCT(e2.salary)) FROM employee e2 WHERE                                      e2.`salary` >   e1.`salary`)

employee-table-1

 

Design patterns usage in Java SE and Java EE

Aside Posted on Updated on

java-logo

 

 

GoF Design patterns used in Java & J2EE.

Creational patterns

Abstract factory (recognizeable by creational methods returning the factory itself which in turn can be used to create another abstract/interface type)

Builder (recognizeable by creational methods returning the instance itself)

Factory method (recognizeable by creational methods returning an implementation of an abstract/interface type)

Prototype (recognizeable by creational methods returning a different instance of itself with the same properties)

Singleton (recognizeable by creational methods returning the same instance (usually of itself) everytime)


Structural patterns

Adapter (recognizeable by creational methods taking an instance of different abstract/interface type and returning an implementation of own/another abstract/interface type which decorates/overrides the given instance)

Bridge (recognizeable by creational methods taking an instance of different abstract/interface type and returning an implementation of own abstract/interface type which delegates/uses the given instance)

  • None comes to mind yet. A fictive example would be new LinkedHashMap(LinkedHashSet<K>, List<V>) which returns an unmodifiable linked map which doesn’t clone the items, but usesthem. The java.util.Collections#newSetFromMap() and singletonXXX() methods however comes close.

Composite (recognizeable by behavioral methods taking an instance of same abstract/interface type into a tree structure)

Decorator (recognizeable by creational methods taking an instance of same abstract/interface type which adds additional behaviour)

Facade (recognizeable by behavioral methods which internally uses instances of different independent abstract/interface types)

Flyweight (recognizeable by creational methods returning a cached instance, a bit the “multiton” idea)

Proxy (recognizeable by creational methods which returns an implementation of given abstract/interface type which in turn delegates/uses a different implementation of given abstract/interface type)

The Wikipedia example is IMHO a bit poor, lazy loading has actually completely nothing to do with the proxy pattern at all.


Behavioral patterns

Chain of responsibility (recognizeable by behavioral methods which (indirectly) invokes the same method inanother implementation of same abstract/interface type in a queue)

Command (recognizeable by behavioral methods in an abstract/interface type which invokes a method in an implementation of a different abstract/interface type which has been encapsulated by the command implementation during its creation)

Interpreter (recognizeable by behavioral methods returning a structurally different instance/type of the given instance/type; note that parsing/formatting is not part of the pattern, determining the pattern and how to apply it is)

Iterator (recognizeable by behavioral methods sequentially returning instances of a different type from a queue)

Mediator (recognizeable by behavioral methods taking an instance of different abstract/interface type (usually using the command pattern) which delegates/uses the given instance)

Memento (recognizeable by behavioral methods which internally changes the state of the whole instance)

Observer (or Publish/Subscribe) (recognizeable by behavioral methods which invokes a method on an instance of another abstract/interface type, depending on own state)

State (recognizeable by behavioral methods which changes its behaviour depending on the instance’s state which can be controlled externally)

Strategy (recognizeable by behavioral methods in an abstract/interface type which invokes a method in an implementation of a different abstract/interface type which has been passed-in as method argument into the strategy implementation)

Template method (recognizeable by behavioral methods which already have a “default” behaviour definied by an abstract type)

Visitor (recognizeable by two different abstract/interface types which has methods definied which takes each the otherabstract/interface type; the one actually calls the method of the other and the other executes the desired strategy on it)

Wait, Notify and NotifyAll in Java

Posted on Updated on

java-logo

 

 

 

It’s became most frequently asked interview question for any level of experience. In this articles we will discuss about wait, notify and notifyAll methods of Object class that help you to make understand about it.

First of all, wait, notify and notifyAll methods are belong to Object class which is final and used to communicate between threads or we can say inter communication between threads on same lock.

A lock is a guard that protect the Object/resource to being access concurrently in multi threading environment and ensure that it will be exclusive available or only one thread can acquire a lock on a Object at a time and rest of the thread will wait in waiting Set until lock get released by acquired thread.

Wait :- It block the current thread execution until  notify/notifiyAll method get called on same lock object. As a Thread call wait(), lock get released and current thread get suspended.

notify:- It wake up only one thread waiting on the same lock and that thread (waiting thread) start execution.

notifyAll :- It wake up all the threads that waiting on same lock. ( CPU scheduler decides which thread wake up first ).

Wait, notify and notifyAll are worked on same object lock. Suppose a thread t1 is waiting on lock A1 object and subsequently another thread t2 send the notification by notify method on same lock A1 then t1 Thread get woke up. If t2 send a notification to another object then t1 never wake up and keep running in suspend mode.

Here, Let’s see in this program how two thread communicate to each other on same lock ( MessageEvent’s object). When Queue’s capacity reach to MAX size then Producer thread hang on their execution and wait for notification. In the same way as Consumer Thread only send the notified on same object when Queue capacity reach down to Zero.
Consumer.Java


package com.waitAndNotify.example;
/**
 * 
 * @author #Ajay
 *
 */
public class Consumer implements Runnable {
	private MessageEvent event;

	Consumer(MessageEvent e) {
		this.event = e;
	}

	public void run() {
			while (true) {
				synchronized (event) {
				if (event.getStorage().size() == 0) {
					event.notify();
				}
				
				try {
					Thread.sleep(600);
				} catch (InterruptedException e) {
					e.printStackTrace();
				}
				System.out.println(event.getStorage().size()+"Removing Element from Queque "
						+ event.getStorage().poll());
			}
		}
	}
}


Producer.Java


package com.waitAndNotify.example;
/**
 * 
 * @author #Ajay
 *
 */
import java.util.Date;

public class Producer implements Runnable {

	private MessageEvent event;

	Producer(MessageEvent e) {
		this.event = e;
	}

	public void run() {
		
		while (true) {
			synchronized (event) {
				try {
					if (event.getStorage().size() == event.getMaxSize()) {
						event.wait();
					}
					event.getStorage().add(new Date());
					System.out.println("Adding Element into Queque ");
					
				} catch (InterruptedException e) {
					e.printStackTrace();
				}
				try {
					Thread.sleep(500);
				} catch (InterruptedException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}

		}
	}

}



MessageEvent.Java


package com.waitAndNotify.example;
/**
 * 
 * @author #Ajay
 *
 */
import java.util.Date;
import java.util.LinkedList;
import java.util.Queue;

public class MessageEvent {

	private final int maxSize;
	private final Queue storage;

	public MessageEvent() {
		this.maxSize = 10;
		this.storage = new LinkedList();
	}

	public int getMaxSize() {
		return maxSize;
	}

	public Queue getStorage() {
		return storage;
	}
}

WaitNotifyMainTest.Java


package com.waitAndNotify.example;
/**
 * 
 * @author #Ajay
 *
 */
public class WaitNotifyMainTest {
	
	public static void main(String args[]){
		MessageEvent storage = new MessageEvent();
		Producer producer = new Producer(storage);
		Consumer consumer = new Consumer(storage);
		Thread t1 = new Thread(producer,"Producer");
		Thread t2 = new Thread(consumer,"Consumer");
		
		t1.start();
		t2.start();
		
	}

}

Output here :- 
Adding Element into Queque 
Adding Element into Queque 
Adding Element into Queque 
Adding Element into Queque 
Adding Element into Queque 
Adding Element into Queque 
Adding Element into Queque 
Adding Element into Queque 
Adding Element into Queque 
Adding Element into Queque 
10Removing Element from Queque Tue Oct 06 21:14:41 IST 2015
9Removing Element from Queque Tue Oct 06 21:14:42 IST 2015
8Removing Element from Queque Tue Oct 06 21:14:42 IST 2015
7Removing Element from Queque Tue Oct 06 21:14:43 IST 2015
6Removing Element from Queque Tue Oct 06 21:14:43 IST 2015
5Removing Element from Queque Tue Oct 06 21:14:44 IST 2015
4Removing Element from Queque Tue Oct 06 21:14:44 IST 2015
3Removing Element from Queque Tue Oct 06 21:14:45 IST 2015
2Removing Element from Queque Tue Oct 06 21:14:45 IST 2015
1Removing Element from Queque Tue Oct 06 21:14:46 IST 2015

 

Please remember, Inter communication never be happened on two different object lock if so then each thread start running separately or Waiting thread is  suspended permanently.

I hope, it would be helpful!!!

Spring 4 with MongoDB Example-1

Posted on Updated on

mongoDB-spring

 

 

 

 

 

 

Here we will show you how to write your first Spring program with MongoDB, also will do CRUD operation.

We used following technologies and tools to configure to build in this program:-

  1. Spring Data MongoDB – 1.5.2.RELEASE
  2. Spring Core – 4.0.3.RELEASE
  3. Eclipse – 4.2
  4. JDK – 1.7
  5. Maven – 3.0.3

Maven Project Structure in eclipse :-

SpringMongoDB-Project-Arc

 

 

 

 

 

 

 

Dependency Jar file in pom.xml


<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

<groupId>com.itexpert</groupId>
<modelVersion>4.0.0</modelVersion>
<artifactId>SpringMongoDBApplication</artifactId>
<name>SpringMongoDBApplication</name>
<version>1.1-SNAPSHOT</version>
<packaging>jar</packaging>

<description>
Root Project For Spring MongoDB Application
</description>
<properties>

<!-- Generic properties -->
<java.version>1.6</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

<!-- Spring -->
<spring-framework.version>4.0.3.RELEASE</spring-framework.version>
<spring-data-mongodb.version>1.5.2.RELEASE</spring-data-mongodb.version>

<!-- Logging -->
<logback.version>1.0.13</logback.version>
<slf4j.version>1.7.5</slf4j.version>

</properties>

<dependencies>
<!-- Spring and Transactions -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring-framework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>${spring-framework.version}</version>
</dependency>

<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-mongodb</artifactId>
<version>${spring-data-mongodb.version}</version>
</dependency>

<!-- Logging with SLF4J & LogBack -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>${logback.version}</version>
<scope>runtime</scope>
</dependency>

</dependencies>
</project>

Spring configuration with annotation:-

Here, we used annotation to connect to mongoDB.


package com.itexpert.app.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.mongodb.MongoDbFactory;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.SimpleMongoDbFactory;

import com.mongodb.MongoClient;

@Configuration
@ComponentScan("com.itexpert")
public class AppConfig {

	
	public @Bean MongoDbFactory mongoDbFactory() throws Exception {
		return new SimpleMongoDbFactory(new MongoClient("localhost",27017), "itexpert");
	}

	
	public @Bean MongoTemplate mongoTemplate() throws Exception {
		MongoTemplate mongoTemplate = new MongoTemplate(mongoDbFactory());
		return mongoTemplate;

	}

}


MongoDB document base Model :-

Here, UserProfile Model represents a @Document in MongoDB:


package com.itexpert.mongo.model;
/**
 * @author #Ajay
 */
import java.io.Serializable;

import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.index.Indexed;
import org.springframework.data.mongodb.core.mapping.Document;

@Document(collection = "UserProfile")
public class UserProfile implements Serializable {

	private static final long serialVersionUID = -5048239448394661430L;

	@Id
	private String id;

	@Indexed
	private String email;

	@Indexed
	private String password;

	private String status = "Unlock";

	private String firstName;
	private String middleName;
	private String lastName;
	private String phone;

	public UserProfile(String email, String password, String status,
			String firstName, String middleName, String lastName, String phone) {
		super();
		
		this.email = email;
		this.password = password;
		this.status = status;
		this.firstName = firstName;
		this.middleName = middleName;
		this.lastName = lastName;
		this.phone = phone;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getStatus() {
		return status;
	}

	public void setStatus(String status) {
		this.status = status;
	}

	public String getFirstName() {
		return firstName;
	}

	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}

	public String getMiddleName() {
		return middleName;
	}

	public void setMiddleName(String middleName) {
		this.middleName = middleName;
	}

	public String getLastName() {
		return lastName;
	}

	public void setLastName(String lastName) {
		this.lastName = lastName;
	}

	public String getPhone() {
		return phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	public static long getSerialversionuid() {
		return serialVersionUID;
	}

       @Override
	public String toString() {
		return String
		.format("UserProfile [id=%s, email=%s, password=%s, status=%s, firstName=%s, middleName=%s,       lastName=%s, phone=%s]",id, email, password, status, firstName, middleName,lastName, phone);
	}

}


Spring DAO Layer

Here, We created a UserProfileRepository @Repository to access the data from mongoDB.

BaseUserDAO.Java


package com.itexpert.dao;
/**
 * @author #Ajay
 */
import java.util.List;

import com.itexpert.mongo.model.UserProfile;

public interface BaseUserDAO {
	
	public void create(T user);
	public void remove(T id);
	public void removeByEmail(String id);
	public void removeAll();
	public T find(String id);
	public List findAll();
	public void update(T user);
	public UserProfile getUserProfileByEmail(String email);

}


UserProfileRepository.Java


package com.itexpert.dao.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Component;

import com.itexpert.dao.BaseUserDAO;
import com.itexpert.mongo.model.UserProfile;

/**
 * @author #Ajay
 */
@Component("userProfileRepository")
public class UserProfileRepository implements BaseUserDAO {

	@Autowired
	private MongoTemplate mongoTemplate;

	@Override
	public void create(UserProfile user) {
		mongoTemplate.save(user);
	}

	@Override
	public void removeByEmail(String userEmail) {
		if (null != userEmail) {
			Query query = new Query();
			Criteria criteria = Criteria.where("email").is(userEmail);
			query.addCriteria(criteria);
			mongoTemplate.remove(query, UserProfile.class);
		}
	}

	@Override
	public UserProfile find(String id) {
		Query query = new Query();
		Criteria criteria = Criteria.where("id").is(id);
		query.addCriteria(criteria);
		return mongoTemplate.findOne(query, UserProfile.class);
	}

	@Override
	public List findAll() {
		return mongoTemplate.findAll(UserProfile.class);
	}

	@Override
	public void update(UserProfile user) {
		mongoTemplate.save(user);

	}

	@Override
	public void removeAll() {
		mongoTemplate.dropCollection(UserProfile.class);

	}

	public UserProfile getUserProfileByEmail(String email) {
		if (email == null || email.isEmpty())
			return null;
		Query query = new Query();
		Criteria criteria = Criteria.where("email").is(email);
		query.addCriteria(criteria);
		return mongoTemplate.findOne(query, UserProfile.class);
	}

	@Override
	public void remove(UserProfile user) {

		mongoTemplate.remove(user);

	}

}

Execute Java Main Class

In this Java main class, we initialized ApplicationContext and test CRUD operation in mongoDB.


package com.itexpert.Main;

import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

import com.itexpert.app.config.AppConfig;
import com.itexpert.dao.impl.UserProfileRepository;
import com.itexpert.mongo.model.UserProfile;

/**
 * @author #Ajay
 */

public class AppMain {

	public static void main(String args[]) {
		ApplicationContext ctx = new AnnotationConfigApplicationContext(
				AppConfig.class);
		UserProfileRepository userRepo = (UserProfileRepository) ctx
				.getBean(UserProfileRepository.class);

		UserProfile user = new UserProfile("experts.itconsultants@gmail.com",
				"*******", "unlock", "Santosh", "Kumar", "Yadav", "011-8987898");
		// Save UserProfile Object into MongoDB
		userRepo.create(user);
		// Print Saved UserProfile Object from MongoDB
		user = userRepo.getUserProfileByEmail("experts.itconsultants@gmail.com");
		System.out.println(" Get UserProfile Record : "+user);
		// Update UserProfile's Phone into MongoDB
		user.setPhone("98987656787");
		userRepo.update(user);
		System.out.println(" Update UserProfile Record : "+user);
		// Delete UserProfile record from MongoDB
		userRepo.removeByEmail("experts.itconsultants@gmail.com");
		// Check remove Object does exist or not
		user = userRepo.getUserProfileByEmail("experts.itconsultants@gmail.com");
		System.out.println(" After Delete Operation, Get UserProfile Record : "+user);

	}
}


Output here :-

23:11:02.579 [main] DEBUG o.s.data.mongodb.core.MongoDbUtils – Getting Mongo Database name=[itexpert]
23:11:02.584 [main] DEBUG o.s.data.mongodb.core.MongoDbUtils – Getting Mongo Database name=[itexpert]
23:11:02.589 [main] DEBUG o.s.data.mongodb.core.MongoTemplate – Saving DBObject containing fields: [_class, _id, email, password, status, firstName, middleName, lastName, phone]
23:11:02.589 [main] DEBUG o.s.data.mongodb.core.MongoDbUtils – Getting Mongo Database name=[itexpert]
23:11:02.607 [main] DEBUG o.s.data.mongodb.core.MongoTemplate – findOne using query: { “email” : “experts.itconsultants@gmail.com”} fields: null for class: class com.itexpert.mongo.model.UserProfile in collection: UserProfile
23:11:02.608 [main] DEBUG o.s.data.mongodb.core.MongoDbUtils – Getting Mongo Database name=[itexpert]
23:11:02.608 [main] DEBUG o.s.data.mongodb.core.MongoTemplate – findOne using query: { “email” : “experts.itconsultants@gmail.com”} in db.collection: itexpert.UserProfile
Get UserProfile Record : UserProfile [id=561164ae98809bcebee2920b, email=experts.itconsultants@gmail.com, password=*******, status=unlock, firstName=Santosh, middleName=Kumar, lastName=Yadav, phone=011-8987898]
23:11:02.616 [main] DEBUG o.s.data.mongodb.core.MongoTemplate – Saving DBObject containing fields: [_class, _id, email, password, status, firstName, middleName, lastName, phone]
23:11:02.616 [main] DEBUG o.s.data.mongodb.core.MongoDbUtils – Getting Mongo Database name=[itexpert]
Update UserProfile Record : UserProfile [id=561164ae98809bcebee2920b, email=experts.itconsultants@gmail.com, password=*******, status=unlock, firstName=Santosh, middleName=Kumar, lastName=Yadav, phone=98987656787]
23:11:02.619 [main] DEBUG o.s.data.mongodb.core.MongoDbUtils – Getting Mongo Database name=[itexpert]
23:11:02.620 [main] DEBUG o.s.data.mongodb.core.MongoTemplate – Remove using query: { “email” : “experts.itconsultants@gmail.com”} in collection: UserProfile.
23:11:02.622 [main] DEBUG o.s.data.mongodb.core.MongoTemplate – findOne using query: { “email” : “experts.itconsultants@gmail.com”} fields: null for class: class com.itexpert.mongo.model.UserProfile in collection: UserProfile
23:11:02.622 [main] DEBUG o.s.data.mongodb.core.MongoDbUtils – Getting Mongo Database name=[itexpert]
23:11:02.622 [main] DEBUG o.s.data.mongodb.core.MongoTemplate – findOne using query: { “email” : “experts.itconsultants@gmail.com”} in db.collection: itexpert.UserProfile
After Delete Operation, Get UserProfile Record : null