Hibernate Maven MySQL Hello World example (XML Mapping)

In this tutorial, we will try to write a small hello world program using Hibernate, MySQL and Maven. We will create a Java project using Maven and will then try to add Hibernate on it.

Following are the tools and technologies used in this project.

  1. Java JDK 5 or above
  2. Eclipse IDE 3.2 or above
  3. Maven 3.0 or above
  4. Hibernate 3.0 or above
  5. MySQL 5.0 or above

1. Database Creation

For this tutorial, we will create a simple table “employe” in MySQL. Use following script to create the table.

CREATE TABLE `employee` (
	`id` BIGINT(10) NOT NULL AUTO_INCREMENT,
	`firstname` VARCHAR(50) NULL DEFAULT NULL,
	`lastname` VARCHAR(50) NULL DEFAULT NULL,
	`birth_date` DATE NOT NULL,
	`cell_phone` VARCHAR(15) NOT NULL,
	PRIMARY KEY (`id`)
)
COLLATE='latin1_swedish_ci'
ENGINE=InnoDB
ROW_FORMAT=DEFAULT
AUTO_INCREMENT=606

Thus, following will be the connection string to connect with MySQL.

Connection URL:	jdbc:mysql://localhost:3306/tutorial
DB Username:	root
DB Password:	<your mysql password>

2. Generate Maven Java project compatible with Eclipse

Open a command prompt and execute following code to generate a Maven Java project.

mvn archetype:generate \
	-DgroupId=net.viralpatel.hibernate \
	-DartifactId=HibernateHelloWorldXML \
	-DarchetypeArtifactId=maven-archetype-quickstart \
	-DinteractiveMode=false

Once you execute above command, a project “HibernateHelloWorldXML” is created. Note that this is a Java project which already has folder structures compatible to Maven.

Once this is done, we will convert it to be compatible with Eclipse. For that executes following command on command prompt.

mvn eclipse:eclipse

3. Import project in Eclipse

Open Eclipse and import the above Java project.

File > Import… > General > Existing Projects into Workspace > Choose above Java project

Once imported, the folder structure will look like following:

hibernate-maven-blank-folder-structure

Important:

In case you get following error after importing project in Eclipse:
hibernate-maven-repo-error

If you are getting this Hibernate Maven Repo error, then you need to define M2_REPO environment variable in eclipse pointing to your local maven repository.

Goto Window > Preferences… > Java > Build Path > Classpath Variables > Define new variable M2_REPO pointing to your local maven repository.
eclipse-maven-repo-environment-variable

Once you will define this variable and rebuild the project, the above error will go.

4. Add Hibernate Dependency to Maven pom.xml

Add following dependencies to Maven 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">
  <modelVersion>4.0.0</modelVersion>
  <groupId>net.viralpatel.hibernate</groupId>
  <artifactId>HibernateHelloWorldXML</artifactId>
  <packaging>jar</packaging>
  <version>1.0-SNAPSHOT</version>
  <name>HibernateHelloWorldXML</name>
  <url>http://maven.apache.org</url>
  <dependencies>
    <dependency>
      <groupId>mysql</groupId>
      <artifactId>mysql-connector-java</artifactId>
      <version>5.1.10</version>
    </dependency>
    <dependency>
      <groupId>org.hibernate</groupId>
      <artifactId>hibernate</artifactId>
      <version>3.2.6.ga</version>
    </dependency>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
  </dependencies>
</project>

Once we have added these dependencies, we will execute following command so that maven will download required Jar files and add the same to eclipse classpath.

mvn eclipse:eclipse

The above step is not mandatory. If you have Maven plugin for Eclipse installed in your IDE (Latest eclipse comes with this plugin built-in) you can just enable Maven dependencies by doing
Right click on project > Maven > Enable Dependency Management.

5. Add Hibernate Configuration XML

Now our project setup is ready. We will add following Hibernate configuration xml file in /src/main/resources folder. Note that this folder is not present in your project structure.

Create a source folder:
Right click on Project > New > Source Folder > Give folder name “/src/main/resources/” and click Finish.

Copy following file in your project.

File: /src/main/resources/hibernate.cfg.xml

<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
        "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
        "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
 
<hibernate-configuration>
    <session-factory>
        <!-- Database connection settings -->
        <property name="connection.driver_class">com.mysql.jdbc.Driver</property>
        <property name="connection.url">jdbc:mysql://localhost:3306/tutorial</property>
        <property name="connection.username">root</property>
        <property name="connection.password"></property>
        
        <!-- JDBC connection pool (use the built-in) -->
        <property name="connection.pool_size">1</property>
        
        <!-- SQL dialect -->
        <property name="dialect">org.hibernate.dialect.MySQLDialect</property>

        <!-- Enable Hibernate's automatic session context management -->
        <property name="current_session_context_class">thread</property>

        <!-- Disable the second-level cache  -->
        <property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
        
        <!-- Echo all executed SQL to stdout -->
        <property name="show_sql">false</property>
        
        <property name="hbm2ddl.auto">validate</property>
 
        <mapping resource="net/viralpatel/hibernate/Employee.hbm.xml"/>
 		
 		 
    </session-factory>
</hibernate-configuration>

One thing we need to make sure in Eclipse is that the Java build path must reflect **/*.xml.
Right click on project > Properties > Java Build Path > Source > Add **/*.xml as follow:
hibernate-java-build-path-include-xml

6. Add Java source code

File: /src/main/java/net/viralpatel/hibernate/Employee.java

package net.viralpatel.hibernate;

import java.sql.Date;

public class Employee {

	private Long id;
	
	private String firstname;
	
	private String lastname;
	
	private Date birthDate;
	
	private String cellphone;

	public Employee() {
		
	}
	
	public Employee(String firstname, String lastname, Date birthdate, String phone) {
		this.firstname = firstname;
		this.lastname = lastname;
		this.birthDate = birthdate;
		this.cellphone = phone;
		
	}
	
	// Getter and Setter methods

}

Above is the Employee POJO class that we will use to fetch data from Employee table. This Java class will be mapped by Hiberate with Employee table. Note that we have define two constructors first default and second with arguements. The second constructor is optional. But note that you must define a default (No-arguement) constructor in your mapping class.

File: /src/main/java/net/viralpatel/hibernate/HibernateUtil.java

package net.viralpatel.hibernate;
 
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
 
public class HibernateUtil {
 
    private static final SessionFactory sessionFactory = buildSessionFactory();
 
    private static SessionFactory buildSessionFactory() {
        try {
            // Create the SessionFactory from hibernate.cfg.xml
            return new Configuration()
            		.configure()
                    .buildSessionFactory();
        } catch (Throwable ex) {
            System.err.println("Initial SessionFactory creation failed." + ex);
            throw new ExceptionInInitializerError(ex);
        }
    }
 
    public static SessionFactory getSessionFactory() {
        return sessionFactory;
    }
}

As discussed in previous article Introduction to Hibernate framework, we have to create SessionFactory instance in order to communicate with Database in Hibernate. We will use a Utility class called HibernateUtil to instantiate SessionFactory.

File: /src/main/java/net/viralpatel/hibernate/Employee.hbm.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
        "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
        "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping package="net.viralpatel.hibernate">

    <class name="Employee" table="EMPLOYEE">
 		<id name="id" column="ID">
            <generator class="native"/>
        </id>
        <property name="firstname" />
        <property name="lastname" column="lastname"/>
        <property name="birthDate" type="date" column="birth_date"/>
        <property name="cellphone" column="cell_phone"/>
	</class>

</hibernate-mapping>

7. CRUD operations in Hibernate

Let us see the basic CRUD operation in Hibernate. We will use Employee table for this.

7.1 Writing (Create) data in Hibernate

Following is the code snippet that insert a row in database.

private static Employee save(Employee employee) {
	SessionFactory sf = HibernateUtil.getSessionFactory();
	Session session = sf.openSession();
	session.beginTransaction();

	Long id = (Long) session.save(employee);
	employee.setId(id);
		
	session.getTransaction().commit();
		
	session.close();

	return employee;
}

...
...
...

// Call the save() method to insert a record in database.
System.out.println("******* WRITE *******");
Employee empl = new Employee("Jack", "Bauer", new Date(System.currentTimeMillis()), "911");
empl = save(empl);

7.2 Reading (Read) data in Hibernate

Below code snippet demos read functionality in Hibernate. Note that there are two methods one to list all the employees and other to read details about just one.

private static List list() {
	SessionFactory sf = HibernateUtil.getSessionFactory();
	Session session = sf.openSession();

	List employees = session.createQuery("from Employee").list();
	session.close();
	return employees;
}
private static Employee read(Long id) {
	SessionFactory sf = HibernateUtil.getSessionFactory();
	Session session = sf.openSession();

	Employee employee = (Employee) session.get(Employee.class, id);
	session.close();
	return employee;
}

7.3 Updating (Update) data in Hibernate

Following is the code snippet to update a record in Hibernate.

private static Employee update(Employee employee) {
	SessionFactory sf = HibernateUtil.getSessionFactory();
	Session session = sf.openSession();

	session.beginTransaction();

	session.merge(employee);

	session.getTransaction().commit();

	session.close();
	return employee;

}

7.4 Remove (Delete) data in Hibernate

Following is code snippet to remove a record in Hibernate.

private static void delete(Employee employee) {
	SessionFactory sf = HibernateUtil.getSessionFactory();
	Session session = sf.openSession();

	session.beginTransaction();

	session.delete(employee);

	session.getTransaction().commit();

	session.close();
}

We have created a file Main.java which will test all these functionality. Following is the complete source code of Main.java.
File: /src/main/java/net/viralpatel/hibernate/Main.java

package net.viralpatel.hibernate;

import java.sql.Date;
import java.util.List;

import org.hibernate.Session;
import org.hibernate.SessionFactory;


public class Main {

	public static void main(String[] args) {
		
		
		// Read
		System.out.println("******* READ *******");
		List employees = list();
		System.out.println("Total Employees: " + employees.size());
		
		
		// Write
		System.out.println("******* WRITE *******");
		Employee empl = new Employee("Jack", "Bauer", new Date(System.currentTimeMillis()), "911");
		empl = save(empl);
		empl = read(empl.getId());
		System.out.printf("%d %s %s \n", empl.getId(), empl.getFirstname(), empl.getLastname());
		
		
		
		// Update
		System.out.println("******* UPDATE *******");
		Employee empl2 = read(1l); // read employee with id 1
		System.out.println("Name Before Update:" + empl2.getFirstname());
		empl2.setFirstname("James");
		update(empl2);	// save the updated employee details
		
		empl2 = read(1l); // read again employee with id 1
		System.out.println("Name Aftere Update:" + empl2.getFirstname());
		
		
		// Delete
		System.out.println("******* DELETE *******");
		delete(empl); 
		Employee empl3 = read(empl.getId());
		System.out.println("Object:" + empl3);
	}
	
	

	private static List list() {
		SessionFactory sf = HibernateUtil.getSessionFactory();
		Session session = sf.openSession();

		List employees = session.createQuery("from Employee").list();
		session.close();
		return employees;
	}
	private static Employee read(Long id) {
		SessionFactory sf = HibernateUtil.getSessionFactory();
		Session session = sf.openSession();

		Employee employee = (Employee) session.get(Employee.class, id);
		session.close();
		return employee;
	}
	private static Employee save(Employee employee) {
		SessionFactory sf = HibernateUtil.getSessionFactory();
		Session session = sf.openSession();

		session.beginTransaction();

		Long id = (Long) session.save(employee);
		employee.setId(id);
		
		session.getTransaction().commit();
		
		session.close();

		return employee;
	}

	private static Employee update(Employee employee) {
		SessionFactory sf = HibernateUtil.getSessionFactory();
		Session session = sf.openSession();

		session.beginTransaction();

		session.merge(employee);
		
		session.getTransaction().commit();
		
		session.close();
		return employee;

	}

	private static void delete(Employee employee) {
		SessionFactory sf = HibernateUtil.getSessionFactory();
		Session session = sf.openSession();
		
		session.beginTransaction();
		
		session.delete(employee);
		
		session.getTransaction().commit();
		
		session.close();
	}
	
}

8. Final project structure

Once you have created all these source files, your project structure should look like following. Note that we have removed the default App.java and AppTest.java generated by Maven as we dont these files.
hibernate-maven-final-project-structure

9. Execute project

Execute the Main.java class and see output.

******* READ *******
Total Employees: 200
******* WRITE *******
201 Jack Bauer 
******* UPDATE *******
Name Before Update:Paula
Name Aftere Update:James
******* DELETE *******
Object:null

That’s All Folks

Today we saw how to write our first Hibernate hello world example using XML Configuration. We used Maven to generate Java project and added Hibernate dependencies into it. Also we saw how to do different CRUD operations in Hibernate.

Download Source

HibernateHelloWorldXML.zip (8 kb)



34 Comments

  • tom 27 February, 2012, 4:33

    I’m getting this error – any ideas why?

    The import org.hibernate.Session cannot be resolved

    • Viral Patel 27 February, 2012, 14:01

      Hi Tom, check if your maven dependencies are properly resolved. It seems that hibernate jar file is not resolved.

    • Tai 7 May, 2014, 13:55

      hi TOm,
      I doing same u, but I cannot run project.
      help me check it, thanks
      error:
      May 07, 2014 3:22:12 PM org.hibernate.cfg.Environment
      INFO: Hibernate 3.2.3
      May 07, 2014 3:22:12 PM org.hibernate.cfg.Environment
      INFO: hibernate.properties not found
      May 07, 2014 3:22:12 PM org.hibernate.cfg.Environment buildBytecodeProvider
      INFO: Bytecode provider name : cglib
      May 07, 2014 3:22:12 PM org.hibernate.cfg.Environment
      INFO: using JDK 1.4 java.sql.Timestamp handling
      May 07, 2014 3:22:12 PM org.hibernate.cfg.Configuration configure
      INFO: configuring from resource: /hibernate.cfg.xml
      May 07, 2014 3:22:12 PM org.hibernate.cfg.Configuration getConfigurationInputStream
      INFO: Configuration resource: /hibernate.cfg.xml
      Exception in thread “main” org.hibernate.HibernateException: /hibernate.cfg.xml not found
      at org.hibernate.util.ConfigHelper.getResourceAsStream(ConfigHelper.java:147)
      at org.hibernate.cfg.Configuration.getConfigurationInputStream(Configuration.java:1405)
      at org.hibernate.cfg.Configuration.configure(Configuration.java:1427)
      at org.hibernate.cfg.Configuration.configure(Configuration.java:1414)
      at net.example.App.main(App.java:18)

  • tom 28 February, 2012, 4:03

    Hi Viral

    Seems I resolved the maven dependencies but im now getting the following errors:

    – The method setFirstname(String) is undefined for the type Employee
    – The method openSession() is undefined for the type SessionFactory
    – The method setId(Long) is undefined for the type Employee

    • Vikash Singh 1 March, 2012, 2:23

      Hi Tom I also faced this problem. Just need to see hibernate.cfg.xml & Employee.hbm.xml file. it should be configured properly. I just correct this one & working fine

      • tom 2 March, 2012, 4:47

        Can you post the amendments you made to get it working?

  • Vikash Singh 1 March, 2012, 2:14

    Hi Viral thanks for this tutorial. I got the output . I am not using Mavan. its just a simple read,Update, & delete Data from database.

  • tom 4 March, 2012, 6:23

    Okay got this working now – Don’t think I had the correct path set for the M2_REPO it should be ~/.M2 for linux but now i’m getting a Null Pointer exception on the delete function.

    Total Employees: 1
    ******* WRITE *******
    607 Jack Bauer
    ******* UPDATE *******
    Exception in thread “main” java.lang.NullPointerException
    at net.viralpatel.hibernate.Main.main(Main.java:33)

    • Manni 23 January, 2013, 6:06

      I think the reason you’re getting this exception is that the auto-increment property for the SQL at the top of the tutorial is set as 606 (hence when the record is created, a value of 607 is assigned for the ‘ID’ as opposed to 1). Try re-creating the table with an auto-increment value of 0 for the ‘create table’ statement instead.

  • John Rozario 7 March, 2012, 17:46

    I am Getting below error:

    : org.apache.maven.archetype.old.ArchetypeTemplateProcessingException: Una
    t as it is not of packaging type ‘pom’
    Unable to add module to the current project as it is not of packaging type ‘pom’

  • suman 29 June, 2012, 13:04

    hello…….i prepared a simple java project using eclipse hibernate nd it was successfully run on eclipse but i want to see output on command form. using mysql database then which command i use ?????????????

  • Arun Menon 25 July, 2012, 23:44

    Thanks for the amazing tutorial .. Absolutely amazing .. Everything is explained clearly.

  • vivek sharma 6 November, 2012, 11:24

    This tutorial has a slight mistake.
    Employee.hbm.xml is placed in package net.viralpate.hibernate which is wrong.
    This Employee.hbm.xml must be placed in the src/main/resources folder.

  • vivek sharma 6 November, 2012, 11:25

    Comments/Suggestions on the above posted by me……..

  • GooBoo 15 November, 2012, 4:48

    Fantastic tutorials. Very straightforward and clear. Thanks so much!

  • Mithun 12 December, 2012, 12:48

    Viral

    It’s good. Also it is very easy to understand

  • Vincent Chan 28 December, 2012, 15:16

    I found the error when execute the program, please advise and step for resolve. Thanks

    錯誤: 找不到或無法載入主要類別 org.apache.catalina.startup.Bootstrap

  • Joe 18 March, 2013, 1:42

    Thanks Viral,
    Good Tutorial, works like a charm

    Joe,

  • kalyan 20 March, 2013, 4:06

    small mistake in the tutorial
    employee.hbm.xml file should be under resources folder…good tutorial thanks a lot

  • Ashish 16 July, 2013, 11:40

    Works perfec…cheerz..!

  • ruchi 19 July, 2013, 11:09

    i am getting the error “could not find or load the main class”… what should i do?

  • Pankaj 9 August, 2013, 18:44

    Just went through your tutorial. It is so thorough. Loved it.

    Thanks!

  • Ferg Smyth 12 August, 2013, 4:04

    Nice tutorial. One issue I experienced was a null pointer being generated.
    It is caused by the auto increment of the table starting at id 606 but we try to load the employee with id 1.

  • DD 28 October, 2013, 1:39

    Great tutorial! Just one hiccup was not finding the mappings Employee.hbm.xml as it was not in the resources.. Moved to resources and worked perfect! I tried to search this question I have but didn’t find exact answers online – any idea why do we have to have getters and setters here? I didn’t have any initially but the build kept failing and had to add them all for the Employee class..

  • ASRAAR 26 January, 2014, 23:21

    Sir ,
    I am trying to implement second level cache in Hibernate and i am getting errors , will you please send me one example to implement the second level cache. I have confusions about which jar fie to be used for implementing it .
    Please sir help me out and that will be your most kindness.

    Regards
    Asraar

  • David 20 February, 2014, 4:06

    Hi There,

    I got an error, do you have any idea why i got it, pls advise me.
    Thank you very much for advance.
    Here is error.
    [ERROR] Failed to execute goal on project HibernateHelloWorldXML: Could not resolve dependencies for project net.viralpatel.hibernate:HibernateHelloWorldXML:jar:1.0-SNAPSHOT: Failure to find javax.transaction:jta:jar:1.0.1B in http://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced -> [Help 1]

  • Tom S 1 March, 2014, 1:50

    Thanks for the very good tutorial!

  • bikash 26 March, 2014, 11:16

    For error : [ERROR] Failed to execute goal on project HibernateHelloWorldXML: Could not resolve dependencies for project net.viralpatel.hibernate:HibernateHelloWorldXML:jar:1.0-SNAPSHOT: Failure to find javax.transaction:jta:jar:1.0.1B in http://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced -> [Help 1]

    Please add below entry in your pom file

    java.net
    http://download.java.net/maven/2/

  • alvin 8 April, 2014, 8:05

    hi I would like to ask on how to auto increment my ID property value in hibernate java. I don’t want my user enter his/her ID value please help me.

  • Carlos M 29 April, 2014, 18:38

    Hi, can you see my related problem in StackExchange?

    http://stackoverflow.com/questions/23364662/how-can-i-catch-password-error-from-configuration-buildsessionfactory-psql

  • Benerjee 11 June, 2014, 13:04

    nice example

  • Neel 16 June, 2014, 16:20

    Hi Viral
    Thanks for such a great Tutorial.
    I am using Postgres instead of mysql could you please tell me what changes i need to do in CREATE TABLE query as auto increment doesn’t work ,and in ID mapping in employee.hbm.xml

  • Sudhakar 31 July, 2014, 14:02

    Your tutorial is fine.
    But each time i need to scroll up click on next topic.
    so better keep navigation buttons like [previous] and [next] on top and bottom.

  • Tek 30 September, 2014, 16:44

    Hi Viral,

    I am trying tutorial, it gives me below error.

    ********** READ ************
    SLF4J: The requested version 1.6.99 by your slf4j binding is not compatible with [1.5.5, 1.5.6, 1.5.7, 1.5.8]
    SLF4J: See http://www.slf4j.org/codes.html#version_mismatch for further details.
    SLF4J: Class path contains multiple SLF4J bindings.
    SLF4J: Found binding in [jar:file:/C:/Users/aaa/Desktop/Personal/Java%20Training/Hibernate/slf4j-1.7.7/slf4j-1.7.7/slf4j-log4j12-1.7.7.jar!/org/slf4j/impl/StaticLoggerBinder.class]
    SLF4J: Found binding in [jar:file:/C:/Users/aaa/.m2/repository/org/slf4j/slf4j-log4j12/1.7.7/slf4j-log4j12-1.7.7.jar!/org/slf4j/impl/StaticLoggerBinder.class]
    SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
    log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).
    log4j:WARN Please initialize the log4j system properly.
    log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
    Exception in thread “main” org.hibernate.exception.GenericJDBCException: Cannot open connection
    at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:140)
    at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:128)
    at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
    at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:52)
    at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:449)
    at org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:167)
    at org.hibernate.jdbc.AbstractBatcher.prepareQueryStatement(AbstractBatcher.java:161)
    at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1616)
    at org.hibernate.loader.Loader.doQuery(Loader.java:717)
    at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:270)
    at org.hibernate.loader.Loader.doList(Loader.java:2449)
    at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2192)
    at org.hibernate.loader.Loader.list(Loader.java:2187)
    at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:452)
    at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:363)
    at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:196)
    at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1258)
    at org.hibernate.impl.QueryImpl.list(QueryImpl.java:102)

    Caused by: java.sql.SQLException: Access denied for user ‘admin’@’localhost’ (using password: NO)
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:996)

    regards,
    Tek

Leave a Reply

Your email address will not be published. Required fields are marked *

Note

To post source code in comment, use [code language] [/code] tag, for example:

  • [code java] Java source code here [/code]
  • [code html] HTML here [/code]

Current ye@r *