Needed to restart Eclipse to do Hibernate changes - java

I'm learning Hibernates and while practising I came across this strange problem. Sometimes, when I do my changes and run the program, all of a sudden my Eclipse console gets stuck showing the last line as Hibernate: drop table UserDetails. To get the program running I need to restart my Eclipse program.
Below is my code.
UserDetails.java
package org.hibernates.dto;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
#Entity
public class UserDetails {
#Id
#Column(name = "User_ID")
private int userId;
#Column(name = "User_Name")
private String userName;
#Temporal(TemporalType.TIME)
private Date date;
public Date getDate() {
return date;
}
public void setDate(Date date) {
this.date = date;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public String getDesription() {
return desription;
}
public void setDesription(String desription) {
this.desription = desription;
}
#Lob
private String address;
private String desription;
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;
}
}
HibernatesTest.java
package org.hibernates.dto;
import java.util.Date;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.cfg.Configuration;
import org.hibernate.service.ServiceRegistry;
public class HibernatesTest {
public static void main(String[] args) {
UserDetails user = new UserDetails();
user.setUserId(1);
user.setUserName("User 1");
user.setDate(new Date());
user.setAddress("User Address");
user.setDesription("User Desription");
Configuration configuration = new Configuration().configure();
StandardServiceRegistryBuilder builder = (StandardServiceRegistryBuilder) new StandardServiceRegistryBuilder()
.applySettings(configuration.getProperties());
ServiceRegistry serviceRegistry = builder.build();
SessionFactory factory = configuration.buildSessionFactory(serviceRegistry);
Session session = factory.openSession();
Transaction tx = session.beginTransaction();
session.save(user);
tx.commit();
session.close();
}
}
hibernate.cfg.xml
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<!-- Database connection settings -->
<property name="connection.driver_class">com.microsoft.sqlserver.jdbc.SQLServerDriver</property>
<property name="connection.url">jdbc:sqlserver://U0138039-TPD-A\\SQLEXPRESS:1433;DatabaseName=HibernatesDataBase</property>
<property name="connection.username">sa</property>
<property name="connection.password">T!ger123</property>
<!-- JDBC connection pool (use the built-in) -->
<property name="connection.pool_size">1</property>
<!-- SQL dialect -->
<property name="dialect">org.hibernate.dialect.SQLServer2005Dialect</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="hbm2ddl.auto">create</property>
<!-- Names the annotated entity class -->
<mapping class="org.hibernates.dto.UserDetails" />
</session-factory>
</hibernate-configuration>
How can I fix this?

You need to close the session factory
factory.close()

Related

org.hibernate.MappingException: An AnnotationConfiguration instance is required to use <mapping class=

I am trying to write my first hibernate annotation application and below are the things that i did
package org.hibernate.pojo;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
#Entity
#Table(name="employee")
public class Employee {
#Id
#GeneratedValue
Integer id;
#Column(name="Employee_Name")
String userName;
#Column(name="Address")
String age;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
/**
* Hi this is to test java commenting
* #return
*/
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getAge() {
return age;
}
public void setAge(String age) {
this.age = age;
}
}
Hibernate.config.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>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.password">$Ailaja12</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/sessions</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="hibernate.bytecode.use_reflection_optimizer">false</property>
<!-- <property name="show_sql">true</property> -->
<!-- <mapping resource="org/hibernate/pojo/Employee.xml"></mapping> -->
<mapping class="org.hibernate.pojo.Employee"/>
<mapping resource="org/hibernate/pojo/Item.xml"></mapping>
</session-factory>
</hibernate-configuration>
Client
package org.hibernate.client;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.AnnotationConfiguration;
import org.hibernate.cfg.Configuration;
import org.hibernate.pojo.Employee;
public class Client {
/**
* #param args
*/
public static void main(String[] args) {
//Starting hibernate environment in your application
Configuration conf = new Configuration();
//2 Loading hibernate configuration file
conf.configure("hibernate.cfg.xml");
SessionFactory factory=new AnnotationConfiguration().configure("hibernate.cfg.xml").buildSessionFactory();
//SessionFactory factory = conf.buildSessionFactory();
Session session = factory.getCurrentSession();
Employee ee = new Employee();
ee.setUserName("Kranthi");
//ee.setId(123);
ee.setAge("Dallas");
Transaction tx = session.beginTransaction();
session.save(ee);
tx.commit();
session.close();
factory.close();
}
}
I am getting below exception
Exception in thread "main" org.hibernate.MappingException: An AnnotationConfiguration instance is required to use
I tried by googling but none of them has worked
and below are the list of jars that i have used
antlr_2.7.6.jar
asm-3.3.1.jar
cglib-2.2.2.jar
domj-1.3.jar
ehcache.jar
hibernate-3.2.jar
javax.persistence.jar
jta.jar
mysql-connector.jar
commonlogging.jar
Add below jar to your class path: hibernate-annotations.3.3.0.GA.jar or add below dependency to your pom file,if you are using maven project
<dependency>
<groupId>hibernate-annotations</groupId>
<artifactId>hibernate-annotations</artifactId>
<version>3.3.0.GA</version>
</dependency>

Enity is not mapped - hibernate

I'm trying to create a small project with hibernate, but i got that error "Type is not mapped [select o from Type o]", I added mapping in hibernate.cfg.xml but still error.
Type.java:
package com.formation.gestionprojet.doa.entity;
import java.io.Serializable;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
#Entity
#Table(name="Type")
public class Type implements Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
#Id
private Long id;
private String name;
private String description;
private String active;
public Type() {
super();
// TODO Auto-generated constructor stub
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getActive() {
return active;
}
public void setActive(String active) {
this.active = active;
}
}
hibernate.org.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 setting -->
<property name ="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="connection.url">jdbc:mysql://localhost:3306/gestion_projet?createDatabaseIfNotExist=true</property>
<property name="connection.username">root</property>
<property name= "connection.password">root</property>
<!-- Dialect -->
<property name="dialect">org.hibernate.dialect.MySQLDialect</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">true</property>
<!-- Drope and re-create the database -->
<property name="hbm2ddl.auto">update</property>
<!-- mapping -->
<mapping class= "com.formation.gestionprojet.doa.entity.Type"/>
</session-factory>
</hibernate-configuration>
hibernateUtil.java:
package com.formation.gestionprojet.utils;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
import org.hibernate.service.ServiceRegistry;
import org.hibernate.service.ServiceRegistryBuilder;
#SuppressWarnings("deprecation")
public class HibernateUtil
{
private static SessionFactory sessionFactory;
private static ServiceRegistry serviceRegistry;
static
{
try
{
Configuration configuration = new Configuration();
configuration.configure("config/hibernate.cfg.xml");
serviceRegistry = new ServiceRegistryBuilder().applySettings(configuration.getProperties()).buildServiceRegistry();
sessionFactory = configuration.buildSessionFactory(serviceRegistry);
}
catch (HibernateException ex)
{
System.err.println("Error creating Session: " + ex);
throw new ExceptionInInitializerError(ex);
}
}
public static SessionFactory getSessionFactory()
{
return sessionFactory;
}
public static Session openSession()
{
return sessionFactory.openSession();
}
public static Session getCurrentSession()
{
return sessionFactory.getCurrentSession();
}
public static void close(){
if(sessionFactory!=null){
sessionFactory.close();
}
}
}
Test.Java
package com.formation.gestionprojet.utils;
import org.hibernate.Session;
public class Test {
static Session session = HibernateUtil.openSession();
public static void main(String[] args) {
session.createQuery("select o from Type o").list();
}
}
First things first, Type is part of the JPA/Hibernate API. So consider renaming it, e.g. MyType or something similar.
Secondly, select is not mandatory in HQL. So you can simply et everything with only FROM clause.
Thirdly, try using fully qualified name of the class in the query.
"FROM com.formation.gestionprojet.doa.entity.MyType"

Why am I getting a org.hibernate.MappingException with this code sample?

.hibernate.MappingException: Repeated column in mapping for entity: com.sample.User2 column: CITY_NAME (should be mapped with insert="false" update="false")
is the Exception I am getting when I run my program that uses Hibernate and MSSQL Server. Here is my code, which is from an online tutorial. I am not sure where the issue lies and I have of course Googled a lot but everything I found had a more obvious error. I can't seem to find it here. Keep in mind, this is my second day using Hibernate/JPA.
com.sample.Address.java:
package com.sample;
import javax.persistence.Column;
import javax.persistence.Embeddable;
#Embeddable
public class Address {
#Column(name="CITY_STREET")
private String street;
#Column(name="CITY_NAME")
private String city;
#Column(name="STATE")
private String state;
#Column(name="CITY_ZIP")
private String zip;
public Address() { }
public Address(String street, String city, String state, String zip) {
this.street = street;
this.city = city;
this.state = state;
this.zip = zip;
}
//Setters and getters generate by Eclipse (omitted for length)
//Note: No annotations on methods
}
com.sample.User2:
package com.sample;
import javax.persistence.AttributeOverride;
import javax.persistence.AttributeOverrides;
import javax.persistence.Column;
import javax.persistence.Embedded;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
#Entity
#Table(name="FancyTable")
public class User2 {
#Id
#GeneratedValue(strategy=GenerationType.IDENTITY)
#Column(name="USER_ID")
private int userId;
#Column(name="USER_NAME")
private String userName;
#Embedded
#AttributeOverrides({
#AttributeOverride(column = #Column(name="HOME_STREET_NAME"), name = "CITY_STREET"),
#AttributeOverride(column = #Column(name="HOME_CITY_NAME"), name = "CITY_NAME"),
#AttributeOverride(column = #Column(name="HOME_STATE"), name = "STATE"),
#AttributeOverride(column = #Column(name="HOME_CITY_ZIP"), name = "CITY_ZIP")})
private Address homeAddress;
#Embedded
private Address officeAddress;
public User2() { }
//Setters and getters generated by Eclipse (Omitted for length)
//Note: No annotations on methods
}
com.sample.HibernateTest3.java:
package com.sample;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
public class HibernateTest3 {
static void run() {
User2 user = new User2();
User2 user2 = new User2();
user.setUserName("Test");
user2.setUserName("Test 2");
Address add1 = new Address();
add1.setStreet("street 1");
add1.setCity("city 1");
add1.setState("state 1");
add1.setZip("zip 1");
Address add2 = new Address();
add2.setStreet("street 2");
add2.setCity("city 2");
add2.setState("state 2");
add2.setZip("zip 2");
user.setHomeAddress(add1);
user2.setHomeAddress(add2);
user.setOfficeAddress(new Address("a", "b", "c", "d"));
user.setOfficeAddress(new Address("X", "X", "X", "X"));
SessionFactory sf = null;
try {
sf = HibernateUtils.createSessionFactory();
Session session = sf.openSession();
session.beginTransaction();
session.save(user);
session.save(user2);
session.getTransaction().commit();
} catch (Exception e) {
System.out.println("ERROR");
e.printStackTrace();
} finally {
try {
HibernateUtils.close();
} catch (Exception ex) {
System.out.println("ERROR 2");
ex.printStackTrace();
}
}
}
public static void main(String[] args) {
run();
}
}
And finally, my hibernate.cfg.xml file...
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<!-- Database connection settings -->
<property name="connection.driver_class">com.microsoft.sqlserver.jdbc.SQLServerDriver</property>
<property name="connection.url">jdbc:sqlserver://localhost:1433;databaseName=sample1</property>
<property name="connection.username">sa</property>
<property name="connection.password">OMMITED</property>
<!-- MSSQL Dialect -->
<property name="dialect">org.hibernate.dialect.SQLServerDialect</property>
<!-- JDBC connection pool (use the built-in) -->
<property name="connection.pool_size">1</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="hbm2ddl.auto">create</property>
<!-- Names the annotated entity class -->
<mapping class="com.sample.User2"/>
</session-factory>
</hibernate-configuration>
Can someone please shed some light and tell me what precisely is causing this error?
From the docs of #AttributeOverride
(Required) The name of the property whose mapping is being overridden
if property-based access is being used, or the name of the field if
field-based access is used.
so you should use a field name instead of column names e.g.
#AttributeOverride(column = #Column(name="HOME_STREET_NAME"), name = "street")
otherwise the column name is not changed and you get your exception

defining collections in hibernate through annotations

I am new to the concepts of hibernate and annotations .Currently I am making program on collections in hibernate.
Actually following is code of my program
person.class
package com;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.ElementCollection;
import javax.persistence.Embedded;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
#Entity
#Table(name = "PesonSubjects")
public class Person {
#Id
#GeneratedValue(strategy = GenerationType.AUTO)
private int id;
private String name;
#ElementCollection
private Set<Subjects> subjectList = new HashSet<Subjects>();
public Set<Subjects> getSubjectList() {
return subjectList;
}
public void setSubjectList(Set<Subjects> subjectList) {
this.subjectList = subjectList;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
MAIN class
package com;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.AnnotationConfiguration;
public class Personmain {
/**
* #param args
*/
public static void main(String[] args) {
SessionFactory sessionfactory = new AnnotationConfiguration()
.configure().buildSessionFactory();
Session session = sessionfactory.openSession();
session.beginTransaction();
Person person = new Person();
person.setName("vikram");
Subjects subjects1 = new Subjects();
subjects1.setAuthor("xxxxxxxx");
subjects1.setISBN(10111);
subjects1.setName("mein kampf");
subjects1.setPublicationHouse("tmh");
person.getSubjectList().add(subjects1);
Subjects subjects2 = new Subjects();
subjects2.setAuthor("bbbbb");
subjects2.setISBN(10112);
subjects2.setName("harry porter");
subjects2.setPublicationHouse("William");
person.getSubjectList().add(subjects2);
session.save(person);
session.getTransaction().commit();
session.close();
}
}
subjects class
package com;
import javax.persistence.Embeddable;
#Embeddable
public class Subjects {
private int ISBN;
private String name;
private String Author;
private String publicationHouse;
public int getISBN() {
return ISBN;
}
public void setISBN(int iSBN) {
ISBN = iSBN;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getAuthor() {
return Author;
}
public void setAuthor(String author) {
Author = author;
}
public String getPublicationHouse() {
return publicationHouse;
}
public void setPublicationHouse(String publicationHouse) {
this.publicationHouse = publicationHouse;
}
}
my configuration file
<?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/AnnotationCollections</property>
<property name="connection.username">root</property>
<property name="connection.password">cccccccc</property>
<property name="hbm2ddl.auto">create</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>
<!-- Echo all executed SQL to stdout -->
<property name="show_sql">true</property>
<mapping class="com.Person" />
</session-factory>
</hibernate-configuration>
Now through the program I want a collection of subjects to enter into a table (I am not annotating subjectList as i want it to be collection and not in tabular format)
ie it should store values in collection fomat
However I am getting the following error
log4j:WARN No appenders could be found for logger (org.hibernate.cfg.annotations.Version).
log4j:WARN Please initialize the log4j system properly.
Exception in thread "main" org.hibernate.MappingException: Could not determine type for: java.util.Set, for columns: [org.hibernate.mapping.Column(subjectList)]
at org.hibernate.mapping.SimpleValue.getType(SimpleValue.java:266)
at org.hibernate.mapping.SimpleValue.isValid(SimpleValue.java:253)
at org.hibernate.mapping.Property.isValid(Property.java:185)
at org.hibernate.mapping.PersistentClass.validate(PersistentClass.java:410)
at org.hibernate.mapping.RootClass.validate(RootClass.java:192)
at org.hibernate.cfg.Configuration.validate(Configuration.java:1099)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1284)
at com.Personmain.main(Personmain.java:14)
Is there something else to define ??
Thanks
For security's sake, keep both classes mapped:
<mapping class="com.Person" />
<mapping class="com.Subjects" />
Besides that, your code seems to be inferring the wrong access type.
Try adding:
#javax.persistence.Access(javax.persistence.AccessType.FIELD)
to Person. Like:
#Entity
#Table(name = "PesonSubjects")
#javax.persistence.Access(javax.persistence.AccessType.FIELD)
public class Person {
If that does not work, try adding to both Person and Subjects.

NamedQueries problem with Hibernate

I used NanedQueries (as follows) in my JPA project Eclipselink as persistence provider:
#Entity
#Table(name = "login")
#NamedQueries({
#NamedQuery(name = "Login.random", query = "SELECT l FROM Login l WHERE l.pk = :randomPk"),
#NamedQuery(name = "Login.max", query = "SELECT MAX(l.pk) FROM Login l")
})
But after I change Hibernate as my persistence provider, I get the following error:
java.lang.IllegalArgumentException: org.hibernate.QueryException: unexpected char: '{' [SELECT...
I use Hibernate 3.2.5 (MySQL dialect)
Not having your exact configuration makes this difficult. But I didn't have an issue with hibernate 3.2.5.GA
I created the following Login Domain object:
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import java.io.Serializable;
#Entity
#Table(name = "login")
#NamedQueries({
#NamedQuery(name = "Login.random", query = "select l FROM Login l WHERE l.pk = :randomPk"),
#NamedQuery(name = "Login.max", query = "select max(l.pk) from Login l")
})
public class Login implements Serializable {
private Long pk;
private String username;
public Login() {}
public Login(Long pk, String username) {
this.pk = pk;
this.username = username;
}
#Id
public Long getPk() {
return pk;
}
public void setPk(Long pk) {
this.pk = pk;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
}
and test class:
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.AnnotationConfiguration;
import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import sky.sns.domain.Login;
import static org.junit.Assert.assertEquals;
public class AnnotationTest {
private static SessionFactory sessionFactory;
private Session session;
private Transaction transaction;
#BeforeClass
public static void initialise() {
sessionFactory = new AnnotationConfiguration().configure("/hibernate-annotation.cfg.xml").buildSessionFactory();
}
#Before
public void setUp() {
session = sessionFactory.getCurrentSession();
transaction = session.beginTransaction();
}
#After
public void tearDown() {
transaction.rollback();
}
#Test
public void createUser() {
Login login = new Login(1L, "foo");
session.save(login);
session.flush();
session.clear();
Login persistedLogin = (Login)session.get(Login.class, 1L);
assertEquals(login.getPk(), persistedLogin.getPk());
}
#Test
public void obtainUserByIdNamedQuery() {
Login login = new Login(1L, "foo");
session.save(login);
session.flush();
session.clear();
Login persistedLogin = (Login)session.getNamedQuery("Login.random").setLong("randomPk", 1L).uniqueResult();
assertEquals(login.getPk(), persistedLogin.getPk());
}
#Test
public void obtainMaxUserIdNamedQuery() {
Login login = new Login(1L, "foo");
session.save(login);
session.flush();
session.clear();
Long maxId = (Long)session.getNamedQuery("Login.max").uniqueResult();
assertEquals(login.getPk(), maxId);
}
}
My hibernate-annotation.hbm.xml file is as follows:
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://www.jboss.org/dtd/hibernate/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/hibernate_owner</property>
<property name="hibernate.connection.username">hibernate_owner</property>
<property name="hibernate.connection.password">hibernate</property>
<!-- Enable Hibernate's automatic session context management -->
<property name="current_session_context_class">thread</property>
<!-- Disable second-level cache. -->
<property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
<!-- Echo all executed SQL to stdout -->
<property name="show_sql">true</property>
<property name="hibernate.format_sql">false</property>
<property name="hibernate.use_sql_comments">false</property>
<mapping class="sky.sns.domain.Login" />
</session-factory>
</hibernate-configuration>
Can you try this in your environment and let me know how you get on

Categories