-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: hbm2ddl.auto is not working properly
PostPosted: Tue Dec 02, 2014 2:09 am 
Newbie

Joined: Tue Dec 02, 2014 1:49 am
Posts: 1
I have created one entity class Emp, I am using hbm2ddl.auto to create tables, below entity related table is creating properly, but before this table in my database some more tables are there, if i use property hbm2ddl.auto as create it need to drop the total schema(total tables) and created the entity related table freshly, old tables are not deleted. That tables are there and this new table is created, I am not getting this create functionality can anyone please clarify my doubt. I used the version 3.6.4.

Emp.java
===============
@Entity
@Table(name="Employe")
public class Emp {
@Id
int empid;
String ename;

public int getEmpid() {
return empid;
}

public void setEmpid(int empid) {
this.empid = empid;
}

public String getEname() {
return ename;
}

public void setEname(String ename) {
this.ename = ename;
}

}

configuration.cfg.xml
==================

<hibernate-configuration>
<session-factory>
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="connection.url">jdbc:mysql://localhost:3306/sample</property>
<property name="connection.username">root</property>
<property name="connection.password">sun</property>
<property name="connection.pool_size">1</property>
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
<property name="show_sql">true</property>
<property name="hbm2ddl.auto">create</property>
<mapping class="in.hib.Emp" />
</session-factory>
</hibernate-configuration>

My main program is this

public class HibApplication {

public static void main(String[] args) {

Emp e=new Emp();
e.setEmpid(2);
e.setEname("pavai");

Configuration cfg=new Configuration().configure();
SessionFactory sf=cfg.buildSessionFactory();
Session session=sf.openSession();
session.beginTransaction();

session.save(e);
session.getTransaction().commit();

}

}


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.