Pages Navigation Menu

Coding is much easier than you think

Table per Class Hierarchy Using Annotation

Posted by on May 20, 2015 in Hibernate, Hibernate Annotation | 0 comments

  In our previous tutorial we got introduced to Inheritance Mapping In Hibernate, In this article I will explain you about Table per Class Hierarchy Inheritance mapping. By this inheritance strategy, we can map the whole hierarchy in a single table. Here, an extra column otherwise known as discriminator column is created in the table to identify the class. In the table, for each record some columns will be empty; those columns for which the particular Java class does not have fields.     The above is the Hierarchy of classes...

read more

Hibernate 4 Hello World example in Eclipse using Annotation

Posted by on May 20, 2015 in Hibernate | 1 comment

  This is the 4th article on Hibernate in java application that describes on how to to save an object from java into the database using Hibernate 4(Hibernate 4 Insert Query). If you have not read my previous articles article on Generic Hibernate Application Requirements and Steps to be followed to use Hibernate in Java, I will recommend that you read that article first. You may want to look at Hibernate Installation/Setup on Eclipse IDE article if Hibernate is not installed already on your system.   As described earlier, the...

read more

Generic Hibernate Application Requirements – XML Mapping

Posted by on May 20, 2015 in Hibernate, Hibernate XML Mapping | 0 comments

  The objective of this example is to understand the general requirement to be followed in creating any hibernate application in Java. You may want to look at Hibernate Installation/Setup on Eclipse IDE article if Hibernate is not installed already on your system.   In general any hibernate application, must have the following 4 files, Model class Mapping XML Configuration XML One java file to access this configuration file/write our logic These files are the minimum requirement to run an hibernate application, in case of...

read more

Struts2 AngularJS integration

Posted by on May 2, 2015 in Ajax, AngularJS, Struts-2 | 5 comments

  In this post, we will learn to implement AJAX calls from a JSP page to a Struts 2 Action class using AngularJS and update the same JSP page back with the Json response from the Struts 2.   Library Required   Since Angular can send and receive only in json format, to handle it you need struts2-json-plugin-2.x.x.jar. This plugin allows you to serialize the Action class attribute which has getter and setter into a JSON object.   How to use?   First of all create a “Dynamic Web Project” in Eclipse and...

read more

AngularJS Interacting with Java Servlet using JSON

Posted by on Apr 26, 2015 in Ajax, AngularJS, Servlet | 6 comments

  In this post, I am going to demonstrate a simple example on how to make AJAX calls from a JSP page to a Servlet using AngularJS and update the same JSP page back with the JSON response from the Servlet. In other words, this post will give you an overview on how to integrate AngularJS in a Java web applications.   There are many JSON libraries available that can be used to pass AJAX updates between the server and the client. I am going to use google’s gson library in this example.   Below are the steps to reproduce to...

read more

Different Between Session.Get() and Session.Load() in Hibernate

Posted by on Apr 23, 2015 in Hibernate | 0 comments

  Often times, you will notice Hibernate developers mix use of session.get() and session load()   At first look both get() and load() seems similar because both of them fetch the data from database, however there are few differences between them, let’s look at those difference with simple example.   package util; import entity.StudentEntity; import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.boot.registry.StandardServiceRegistryBuilder; import...

read more

Table per Concrete Class Example using XML – Hibernate4

Posted by on Apr 19, 2015 in Hibernate | 0 comments

  In case of Table per concrete class, two tables for each subclass are created. The super class variables are placed in each subclass.   In this example, we are going to use hb2ddl.auto property to generate the table automatically. So we don’t need to worry about creating tables in the database.     The above is the Hierarchy of classes involved. Here Employee is the super class for PermanentEmployee and ContractEmployee classes. Now Let us create Java classes for the above hierarchy to implement   Model...

read more

Table per Subclass Example using XML file

Posted by on Apr 16, 2015 in Hibernate | 0 comments

  In case of Table per Subclass, subclass mapped tables are related to parent class table by primary key and foreign key relationship.   The <joined-subclass> element of class is used to map the child class with parent using the primary key and foreign key relation.   In this example, we are going to use hb2ddl.auto property to generate the table automatically. So we don’t need to worry about creating tables in the database.   Let’s see the hierarchy of classes that we are going to map.   The above...

read more

Ajax Cascading DropDownList in JSP & Servlet using JQuery and JSON

Posted by on Apr 12, 2015 in Ajax, jQuery, Servlet | 5 comments

    There are times in a web application where you want to populate a dropdown list based on the value of another drop down list. In this example, we will be creating a dropdown list for favorite spots and favorite player; since this scenario involves in returning complex java objects like lists, maps, etc, so I’m using JSON for this purpose. In the article on AJAX in Servlet & jsp using JQuery I have demonstrated on returning simple object from servlet to jsp via jquery.   Library required   Google...

read more

Refresh DIV Content Without Reloading Page using jQuery

Posted by on Apr 9, 2015 in jQuery | 0 comments

  In my previous post, I explained about making AJAX calls to a servlet from a JSP page and updating a part of the JSP page with the response from the Servlet.   This article will help you to Refresh DIV Content Without Reloading Page using jQuery with simple html page.     Refresh Div without Reloading Page Refresh DIV Content Without Reloading Page using jQuery Demo by Mohaideen - @ SimpleCodeStuffs This div will get refreshed for every 2 seconds..!   Another must read...

read more