I am using hibernate as ORM tool is my project. It worked fine for me previously and created table properly.My last table had around 200 columns ,after some changes now my table need 150 columns.So I have edited my mapped pojo class .Have removed extra attributes and getters setters from it Hb2ddl works perfectly as I can see drop table, create table syntax on my console.But new Table generated by hibernate consists some old column schema values too , which are not being used and does't exist in the mapped pojo?
For checking purpose when I change pojo name then it generates rigth table with 150 columns.
Have added image for first condition.Values below mir_ids are from old schema.I have not used them im my mapped pojo.
Image1: :
And when to check I try a differnt name for pojo.It I get correct output .(Those are 166 rows)
Image2: :
Those extra value's are not present and works perfectly fine.But I don't want to do it.I will need to change table name in all project.
what can be the reason for it ? How to correct it?
Note: I have edited mapped class name and it worked for me.I got a new table created with 151 colums as I needed but hibernate still creates that old table itself.Even there is no mapping of that in hibernate.cfg.xml file.
Code for hibernate.cfg.xml file:
<property name="hibernate.connection.autocommit">false</property>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.password">abhijeet</property> <property
name="hibernate.connection.url">jdbc:mysql://localhost:3306/jdbctest</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.current_session_context_class">thread</property>
<property name="hibernate.connection.pool_size">1</property>
<!-- <property name="hibernate.connection.datasource">jdbc/mysql_pool1</property> -->
<property name="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</property>
<property name="hibernate.show_sql">true</property>
<property name="hibernate.hbm2ddl.auto">create-drop</property>
<mapping class="com.abhijeet.nabi.pojos.TablePojo" />
Why does hibernate creates an extra table , for which I don't have any mapping.