May 22, 2017

Tusshar Kapoor, Sonakshi Sinha, Evelyn Sharma dress alike at Half Girlfriend screening!!

A recent special screening of the Arjun Kapoor-Shraddha Kapoor movie Half Girlfriend saw an unusual synchronization of minds that flummoxed many.

Amitabh Bachchan, Shabana Azmi, Sonu Nigam talk women empowerment

In the movie Bahubali 2, the character of Amarendra Bahubali played by Prabhas feels that merely chopping off the fingers of a man trying to grope women is not enough punishment. He beheads him as capital punishment. Now that can happen in the make-believe world of movies where things are often glorified and gory-fied. But in a dignified cultured society with better sensibilities, matters have to be drastically different.

May 19, 2017

Emma Watson’s dream comes true!

Emma Watson is much excited these days as her dream has come true! The actor has finally got a chance to work with her dream actor ‘Tom Hanks’ in their upcoming film “The Circle”.

The Harry Potter star confesses that it was an honour for her to share screen space with Hanks in their upcoming directoral by James Ponsoldt. Based on David Eggers’ book with same name, this techno-thriller hits Indian Cinemas under the banner of MVP Entertainment on May 19.

May 17, 2017

'God-woman' Radhe Maa turns actress!

Mamtamayi Radhe Maa aka Sukhvinder Kaur, who had grabbed national attention with an array of controversies is back with a bang. Well, this time in a brand new avatar.

May 15, 2017

RJ Malishka makes Bollywood debut with Vidya Balan's Tumhari Sulu..

The growing exciting cast of T-Series and Ellipsis Entertainment's Vidya Balan-starrer, Tumhari Sulu, has been in the news. From theatre ace Manav Kaul who will play Sulu's husband to the sexy Neha Dhupia who will essay the role of a radio boss, the quirky slice-of-life comedy, being directed by noted ad filmmaker Suresh Triveni, has become the talk of the town.

Is Shah Rukh Khan-luck rubbing off on Evelyn Sharma?

And you thought only Shah Rukh Khan and Salman Khan had fans waiting for them outside their Bandra residences. Wait till you are surprised!

A week ago, the Yeh Jawaani Hai Deewani (YJHD) actress Evelyn Sharma was taken aback to find two fans from Punjab waiting for autographs and selfies outside her Bandra abode. When she was preparing to leave for a shoot, they walked up to her and told her they had been coming there from two days and standing below her building for a couple of hours to get a peek of the actress.

May 14, 2017

Popular TV stars describe their mom in one sentence..

On the occasion of Mother’s Day, we spoke to a few popular TV celebs and asked them to describe their mom in one sentence. Here is what they said:
Urvashi Dholakia, who will be soon seen in yet another power packed role in Ekta Kapoor's Chandrakanta affirmed that she has a great respect for all the mother's not just today but everyday. "As a child, we wake up every morning and get to work and start our day. But Mothers wake up and pray. They pray for our joyous life, they pray so that we can remain strong. If they sense any trouble coming at us, they cut it like a knife. We as children need to understand that she will 'always' be holding our hand," says Urvashi.

IN PICS: Jamai Raja actor Sandit Tiwari ties the knot..

Sandit Tiwari, who did the shows like Beend Banoongaa Ghodi Chadhunga, Me Aajji Aur Sahib,  Jamai Raja and Mahisagar recently tied knot with his long time girlfriend Priyankona Das. She is a software professional and works with a leading IT firm.

May 10, 2017

Sridevi’s MOM to release in four languages!

 Boney Kapoor’s MOM presented by Zee Studios featuring superstar Sridevi, Nawazuddin Siddiqui and Akshaye Khanna will now be releasing nationwide in three languages including Tamil, Telugu and Malayalam besides Hindi.

Sridevi & A R Rahman promotes MOM on the sets of ‘Sa Re Ga Ma Pa Lil Champs 2017’!

Mother’s Day is just around the corner and to celebrate this special day, two special guests – superstar Sridevi and music maestro A R Rahman recently visited the sets of the singing reality show – Sa Re Ga Ma Pa Lil Champs to promote their forthcoming film, MOM.

Nadeem back with Suneel Darshan’s Ek Haseena Thi Ek Deewana Tha..

After launching the motion poster of Ek Haseena Thi Ek Deewana Tha, filmmaker Suneel Darshan has unveiled the musical teaser of his forthcoming musical thriller starring Upen Patel, Shiv Darshan and introducing sensational new find Natasha Fernandez.

May 09, 2017

Urvashi Dholakia learns horse-riding for Chandrakanta..

Urvashi Dholakia, who played the iconic role of Komolika Basu in 'Kasautii Zindagii Kay' will be playing an antagonist in Ekta Kapoor’s upcoming show Chandrakanta. She is playing a fearless, ambitious queen Iravati in the show, and is required to ride a horse. To get into the skin of the character, she went the extra mile and underwent extensive training in horse riding.

May 08, 2017

'Suit Suit' sensation Guru Randhawa sings for Vidya Balan's Tumhari Sulu..

The Punjabi "Suit Suit" sensation Guru Randhawa visited the set of T-Series & Ellipsis Entertainment's comedy "Tumhari Sulu" today. Guru's song Suit Suit was a chartbuster and he is now making aggressive inroads into Bollywood.

May 07, 2017

Hibernate Tutorial..

Hibernate is an ORM tool and is used in the data layer of an application. It implements JPA (Java Persistence API), which is a set of standards that have been prescribed for any persistence implementation.

Suppose you want to store user information in the database. Most of the time, you will be using a relational database. You will be creating a user table, which has the columns corresponding to variables present in your Java class. i.e a class corresponds to a table, and an object of a class corresponds to a row in the table.  We need to write SQL queries, to select, insert, update details in the user table.

We have objects in Java, but not in the database, so we need to take the values of member variables from Java object and map it in the SQL queries. If you add a new column in the table, then you need to make changes in Java classes.

What if an object has a reference to another object, then you need to create tables with foreign keys.

Also, you need to manually do the data-type conversion.

Hibernate solves the above pain points.

Suppose, you want to save the object in the database, without Hibernate, we need to do following things:
  • We need to create the database table.
  • We need to do JDBC configuration.
  • We need to write a model object, which is the object which we need to save.
  • A service method, which will create this model object.
  • A DAO class, which will generate the SQL queries to save the object.
If you are using Hibernate, then you need to:
  • You need to write a hibernate configuration file (hibernate.cfg.xml), which will give information to Hibernate to which database it needs to connect.
  • Create a model object.
  • Write a service method, which will create an instance of a model object and pass it to Hibernate API.
Hibernate Annotations
  • @Entity annotation is used to mark the class as an Entity bean. So the class should have at least have a package scope no-argument constructor. When a Hibernate finds a class with @Entity annotations (entry of that class should be present in hibernate.cfg.xml), it will recreate it as a table in your database. If you specify name attribute with @Entity annotation e.g @Entity (name="User_Details"), then Hibernate will insert/ update/ fetch the record from User_Details, instead of from the table, whose name is same as Entity class name.
  • @Id annotation is used to specify the identifier property of the entity bean and should be kept above the member variable which you want to be used as primary key. The placement of the @Id annotation determines the default access strategy that Hibernate will use for the mapping. If the @Id annotation is placed over the field, then filed access will be used. Instead, if it placed over the getter method of that field, then property access will be used. Here we use property access.
  • @GeneratedValue annotation will tell hibernate to automatically generate values using an internal sequence. Therefore we don’t have to set it manually. We can use it along with @Id and make our primary key automatically generated rather than setting each time. We can also specify a strategy on how the values will be generated like @GeneratedValue(strategy=GenerationType.AUTO). AUTO is the default if we don’t give a strategy. Other values are IDENTITY, SEQUENCE and TABLE, which are actually dependent on the database that we use. AUTO is the preferred option as hibernate will chose the best strategy for us automatically.
  • @Column annotation is used to specify the details of the column to which a field or property will be mapped. If the @Column annotation is not specified by default the property name will be used as the column name. 
  • @Table annotation is used to specify the table to persist the data. The name attribute refers to the table name. If @Table annotation is not specified then Hibernate will by default use the class name as the table name. 
  • @Basic annotation without any parameters is same as without having it. It just tells hibernate to treat it is a field that needs to be saved and is the same behavior without it. However, the use comes when it is used along with its parameters. By default, it is same as @Basic (optional=true) and the field can be not supplied any value (not calling getter) or supplied with a null value. @Basic (optional=false) makes it a non-null field.  If not supplied any value (not calling getter) or supplied with a null value with @Basic (optional=false), you will get an exception: org.hibernate.PropertyValueException: not-null property references a null or transient value.
  • @Transient annotation tells Hibernate not to save this field. Even without this annotation, a static variable or a transient variable is not saved. So the behavior is same for a static variable, transient variable or any other variable with @Transient annotation. If annotations are placed over getters, those placed over fields are ignored and only getters are considered. Even other fields are ignored and all other getters are considered. Hence if you have annotations over any of your getter, then a static variable, transient variable or any other variable will be saved as usual if it has a getter.
  • @Temporal annotation over a date field tells hibernate the format in which the date needs to be saved. For instance, by default, the date will be saved as a timestamp, but to save date alone we can use @Temporal(TemporalType.DATE).
  • @Lob annotation tells Hibernate that this is a large object, not a simple object. So Hibernate creates a CLOB or BLOB based on the type of the object. For instance, if @Lob comes over a string, then Hibernate assumes to use a character large object (CLOB). In the case of array, it will treat it as BLOB.
  • @Embeddable and @Embedded annotations are used when you want to embed one entity in another entity. The attributes of an entity can be common attributes of more than one entity. An embeddable entity can be embedded in more than one entity. 

First Hibernate Application To Save And Fetch Objects using Hibernate APIs
We will be using SQL server 2012 for writing our Hibernate application.

Hibernate uses XML mapping file for the transformation of data from POJO to database tables and vice versa. We will first we need to write a configuration file.  Here is the example of hibernate.cfg.xml for SQL server
< ?xml version='1.0' encoding='UTF-8'? >
< !DOCTYPE hibernate-configuration PUBLIC
        "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
        "" >
< hibernate-configuration >
    < session-factory >
     < !-- Database connection settings -- >
        < property name="hibernate.connection.driver_class" >< /property >
        < property name="hibernate.connection.url" >jdbc:sqlserver://;databaseName=scrutinydb< /property >
        < property name="hibernate.connection.username" >khs< /property >
        < property name="hibernate.connection.password" >khs< /property >
        < !-- JDBC connection pool (use the built-in) -- >
        < property name="connection.pool_size" >1< /property >

        < !-- SQL dialect -- >
        < property name="dialect" >org.hibernate.dialect.SQLServer2012Dialect< /property >

        < !-- Disable the second-level cache  -- >
        < property name="cache.provider_class" >org.hibernate.cache.internal.NoCacheProvider< /property >

        < !-- Echo all executed SQL to stdout -- >
        < property name="show_sql" >true< /property >

        < !-- Drop and re-create the database schema on startup -- >
        < property name="" >create< /property >

        < !-- Names the annotated entity class -- >
        < mapping class="com.test.khs.UserDetails"/ >
    < /session-factory >
< /hibernate-configuration >

We need to write the Model Class with annotations and mention it in 'mapping' tag of hibernate.cfg.xml
package com.test.khs;
import javax.persistence.Entity;
import javax.persistence.Id;

public class UserDetails {
    private int userId;
    private String userName;

    public int getUserId() {
        return userId;
    public void setUserId(int userId) {
        this.userId = userId;
    public String getUserName() {
        return userName;
    public void setUserName(String userName) {
        this.userName = userName;

Hibernate will create UserDetails, with two columns userId, userName and when you call save() method, the object will be saved in UserDetails table.
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
import com.test.khs.UserDetails;
public class TestHibernate {
    public static void main(String[] args) {
        UserDetails user1=new UserDetails();
        user1.setUserName("Himaanshu Shuklaa");
        //create a session factory
        SessionFactory sessionFactory=new Configuration().configure().buildSessionFactory();
        //get the session from session factory       
        Session savesession=sessionFactory.openSession();
        //to save the object in hibernate;
        Session fetchsession=sessionFactory.openSession();
        //fetch based on the primary key
        user1=fetchsession.get(UserDetails.class, 1);
        System.out.println("*****fetched UserDetails:"+user1.getUserName()+", Id="+user1.getUserId());

If you execute TestHibernate again, then it will delete the previous record the UserDetails table and insert the new one again. This happens because of '' property in hibernate.cfg.xml, which was,
< property name="" > create < /property >

To retain the previous data, you need to change 'create' to 'update'.

If you set to update and then execute TestHibernate class again, then it will insert a new record in the table.

Suppose you have executed TestHibernate with as 'create' or with 'update' and then added a new variable in UserDetails class. An error 'Invalid column name' when you try to execute TestHibernate with as 'update'.

Hibernate creates and insert the record in the UserDetails table, where the name of the table is same as Entity class name. What if the class name is different? Or you want to insert the record in a table with the different name? To resolve this issue by specifying the name in @Entity annotation. Also, by default the property name will be used as the column name, you can change it with the name property of @Column annotation.

Example of Hibernate Annotations @Embeddable and @Embedded

This example will add Address details in the Employee table.
import javax.persistence.Column;
import javax.persistence.Embeddable;

public class Address {
    @Column(name = "street")
    private String street;
    @Column(name = "city")
    private String city;
    public String getStreet() {
        return street;
    public void setStreet(String street) {
        this.street = street;
    public String getCity() {
        return city;
    public void setCity(String city) { = city;

import javax.persistence.AttributeOverride;
import javax.persistence.AttributeOverrides;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;

@Table(name = "employee_details")
public class Employee {
    @Column(name = "id")
    private int empId;
    @Column(name = "emp_name")
    private String empName;
    @Column(name = "emp_address")
            @AttributeOverride(name = "street", column = @Column(name = "emp_add_street")),
             @AttributeOverride(name = "city", column = @Column(name = "emp_add_city"))})
    private Address empAddress;
    public int getEmpId() {
        return empId;
    public void setEmpId(int empId) {
        this.empId = empId;
    public String getEmpName() {
        return empName;
    public void setEmpName(String empName) {
        this.empName = empName;
    public Address getEmpAddress() {
        return empAddress;
    public void setEmpAddress(Address empAddress) {
        this.empAddress = empAddress;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;

public class EmbedEmployeeTest {
    public static void main(String[] args) {
        Employee employee=new Employee();
        Address empAddress=new Address();
        employee.setEmpName("K Himaanshu Shuklaa");
        //create a session factory
        SessionFactory sessionFactory=new Configuration().configure().buildSessionFactory();
        //get the session from session factory       
        Session savesession=sessionFactory.openSession();
        //to save the object in hibernate;

When you execute EmbedEmployeeTest, it will create employee_details table with id, emp_add_city, emp_add_street, emp_name as the columns with values 1, Kempten, Alfred-weitnauer-straße, K Himaanshu Shuklaa respectively.

May 05, 2017

May 03, 2017

This is how yesteryear actress Mumtaz looks like..

Yesteryear actress Mumtaz, started her career as a child actress in Sone Ki Chidiya in 1958. After that the pretty actress had worked with most of the leading heroes and delivered numerous hits like Do Raste, Roti, Dushman, Apna Desh, Aap Ki Kasam, Sachcha Jhottha, Bharmchari, Hare Rama Hare Krishna etc.

May 02, 2017

Apache ANT Interview Questions And Answers

ANT stands for Another Neat Tool and is a Java based build tool from Apache Software Foundation. Apache Ant's build files are written in XML and they take advantage of being open standard, portable and easy to understand.

As a developer, we compile the code, package the binaries, deploy those binaries to the test server, test the changes and sometimes copy the code from one location to another. We can automate these tasks in a simplier way by using Apache Ant.

First Look Of Baaghi 2

May 01, 2017

A Grateful Crow..

During summers, I keep some bowls of fresh water in the balcony for birds. Every day I rinse, and refilled them with fresh water. To be very frank, I have a super selfish motive behind this. I believe, our present time is seed time; in the other world we shall reap as we sow now. I am a water baby, I do this so that I will always get sheer abundance of water.
RSSChomp Blog Directory