Hibernate and it’s Architecture

Hibernate is an Object Relational mapping framework. What it does is it takes rows in relational database and turns them into java objects. If we are doing Object relational mapping in our DAO with sql it breaks unexpectedly when some mistake in query (I faced this often). So hibernate enable us to get rid of sql in DAO classes. We can do our operations with db with fewer queries and less error prone. Mappings will maps data in our java objects to the fields in relational database. We can also use annotations to do these mappings. Hibernate itself is a

Read more

What are Microservices Architecture and why it need

A fellow named Adrian Cockcroft from Battery Ventures formerly Chief Architect Netflix cloud explained Microservices are Loosely Coupled service oriented architecture with bounded context. Simply, With Microservices A Single application be made of suite of smaller services very light weight typically http around the certain business context. Micro services Architecture are popular because of its, Desire for faster changes: In a monolithic application we have seen the change cycles of project are tied together, few batched releases and integrated set of software and procedure for installing and we don’t do software updates too often, its quarterly probably more often every

Read more

Writing URLClassLoader

Class loading a major concept when it comes to JVM internals. We can load jars from multiple locations from DB and From Remote location and we can also create our own class loader instead of using URLClassLoader. Output:  com.sfos.Message@15db9742 hash code of Object With the help of URLClassLoader I am calling Messager.jar which contains Message class. The URLClassLoader will take an array of jars to load not a specific type.  The problem with this example is that when I call new instance, I only get back something of type Object. Now I know that I should be getting back something

Read more

Spring adding a spring security filter

Dealing with users and accounts is the part of domain of spring security. Now we gonna use spring security to protect our website from people who shouldn’t have access or shouldn’t have an account, people who didn’t have an account wont be able to access certain areas of website. We gonna use spring security to manage our user accounts as well as the whole process. we need to add a special spring filter that will handle all the requests coming to our application and we will figure out weather the people are allowed in or not. Spring will create a

Read more

Spring mvc adding HIbernate form validation support

To enable Hibernate form validation support to your spring-mvc project we need some jars, Add the below dependencies to your existing maven pom and update your maven project. run the application by downloading the source code provided and check the control flow and how every thing is validated. Updated this in Pom.xml home.jsp OffersController.java createoffer.jsp Offer.java output: If any input is wrong according to our validation rules given to Offer.java the below errors will get. Download The complete source code is here offers – with hibernate validation support If you found an error, highlight it and press Shift + Enter or

Read more

Creating a UI form and process with spring mvc controller

This is a basic tutorial of getting form values to spring controller and printing them in console. we have a page called createoffer.jsp which it will take form values. createoffer.jsp OffersController.java output: Offer [id=0, name=krishna, email=pbkrishna.java, text=hello, any doughts on spring clear here. Its Free!] Download the complete source code is here http://sourceforopensource.com/wp-content/uploads/2016/06/offers.zip If you found an error, highlight it and press Shift + Enter or click here to inform us.

Read more

Spring mvc Creating a ServiceLayer

In this post we are going to see how to add service layer to our spring application. And we gonna use that to get data from our database via our spring stuff rather than simply via JSTL connecting to our dataSource. Now we are gonna give a structure to our project by adding service layer. I will explain little bit about whats happening with the code below. There is a database named sfos, in which it has a table named offers, the table have some data. Now our task is to pull the data from the database using spring mvc.

Read more

Spring Loading Bean Contexts with ContextLoaderListener

Up to now we have seen, Connecting DAO to our spring mvc application. But in order get requests to OffersDAO.java class we need to give access of this class to the browser. By using ContextLoaderListener. We configured our OffersDao.java to dao-context.xml and then we have to configure dao-context.xml to web.xml. dao-context.xml web.xml we just added the configuration here. If you found an error, highlight it and press Shift + Enter or click here to inform us.

Read more

Spring mvc Adding DAO Code

Now we gonna see how to add DAO code to our existing spring mvc application. web.xml OffersController.java offers-servlet.xml home.jsp Upto now we have seen the working of spring mvc application.But, what if we have a DAO(data access object) code to be added to our web application. Which the DAO will do some CRUD operations. Lets have a look of adding the DAO code to Our spring mvc application. we have the Offer pojo. Offer.java we have the OffersDAO, in this class we have configured the DataSource and JdbcTemplate. To know how to configure Datasource and JdbcTemplate http://sourceforopensource.com/spring-querying-using-jdbc-template/. OffersDAO.java dao-context.xml Conclusion: In

Read more
1 2 3 4