Java

Java is a set of computer software and specifications developed by Sun Microsystems, which was later acquired by the Oracle Corporation, that provides a system for developing application software and deploying it in a cross-platform computing environment. Java is used in a wide variety of computing platforms from embedded devices and mobile phones to enterprise servers and supercomputers.

123

Tuesday, January 27, 2015

No data type for node: org.hibernate.hql.internal.ast.tree.IdentNode \-[IDENT] IdentNode: 'e' {originalText=e}

org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.lang.IllegalStateException: No data type for node: org.hibernate.hql.internal.ast.tree.IdentNode  \-[IDENT] IdentNode: 'e' {originalText=e}HQL query:Query query = session.createQuery("SELECT e FROM Employee");Problem: In the above query, 'e' alias name is given in Employee table.Solution: Query query = session.createQuery("SELECT...

Sunday, January 25, 2015

How to display all tables in different databases

In this article, we will see how to connect to the different databases(MySQL, Oracle, PostgreSQL, DB2) and how to display the all table names. MySQLConnect to the database:mysql [-u username] [-h hostname] database-nameTo list all databases, in the MySQL prompt type:show databasesThen choose the right database:use <database-name>List all tables in the database:show tablesDescribe a table:desc <table-name>OracleConnect to the database: connect username/password@database-name;To list all tables owned by the current user, type:select...

Find duplicate elements in ArrayList

There are four ways is there to find duplicate element in arraylist.Using ArrayList contains method   Using HashSetUsing HashMapWithout using abovepackage com.varasofttech;import java.util.*;/** * @author Ranga Reddy * @date Jan 25, 2015 * @version 1.0 * @description : Displaying the all duplicate elements and how many times it found */class Application { public static void main(String args[]) { List<String> names = getNames(); System.out.println("Displaying all names : "+ names); String duplicateName...

Creating Custom Generator class in Hibernate

In this post, we are going to learn how to create custom generator class in hibernate.Hibernate supports many built in generator classes like assigned, sequence, increment, identity, native etc. But some requirements these generator classes we can't use. For example while creating new Employee record, i want to insert employee id is Emp00001, Emp00002, etc like that. There is no built in generator classes support this type of primary key generated...

Thursday, January 22, 2015

CRUD Operations Using Hibernate

Below example explains how to perform Create, Read, Update and Delete (CRUD) operations using Hibernate.Tools: Eclipse,MySQLHiberante 4.3.6Project Structure:Step1: Creating the POJO classEmployee.javapackage com.varasofttech.pojo;import java.io.Serializable;public class Employee implements Serializable { private static final long serialVersionUID = -9001198124094210159L; // properties private long id; // identifier private...

Creating our Own Hibernate Template class

Let us see how to develop our own Hibernate Template class.HibernateTemplate.javaimport java.io.Serializable;import java.util.List;import org.hibernate.HibernateException;import org.hibernate.Query;import org.hibernate.Session;import org.hibernate.SessionFactory;import org.hibernate.Transaction;import com.varasofttech.util.HibernateUtil;public class HibernateTemplate { private SessionFactory sessionFactory = null; public HibernateTemplate() { sessionFactory = HibernateUtil.getSessionFactory(); } public Serializable save(Object...

Sunday, January 18, 2015

Caused by: java.lang.ClassNotFoundException: javax.servlet.SessionCookieConfig

Exception:Caused by: java.lang.ClassNotFoundException: javax.servlet.SessionCookieConfig        at java.net.URLClassLoader$1.run(URLClassLoader.java:372)        at java.net.URLClassLoader$1.run(URLClassLoader.java:361)        at java.security.AccessController.doPrivileged(Native Method)        at java.net.URLClassLoader.findClass(URLClassLoader.java:360)        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)        at...

Saturday, January 3, 2015

Hibernate Object Identity and Equality

There are several mismatches between the Object oriented system and Relation system. In that one of the important mismatch is Object identity and equality.There are three ways to tackle identity: two ways in java world, and one is relational world. Java provides two ways for object identity and equality. If two objects are called identical when they point to the same reference in memory.If two objects are considered equal when they contain similar data.Java offers the equals() method and == operator to support equality...