Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

SchemaUpdateTask executes create query

 
Ganesan Kaliyaperumal
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am using the following ant target to synchronize and update the DB.

<target name="schema_update" depends="persistence_config"
description="Update missing columns DB schema from the O/R mapping
files">
<taskdef name="schemaupdate"
classname="net.sf.hibernate.tool.hbm2ddl.SchemaUpdateTask"
classpathref="project.class.path" />

<schemaupdate
properties="${release.dir}/${config.dir}/hibernate.properties"
quiet="no" text="no" >
<fileset dir="${config.hbm.dir}">
<include name="**/*.hbm.xml"/>
</fileset>
</schemaupdate>
</target>

While running this target the ant conosle shows statements as follow,

"create table user_role (fk_role bigint not null, fk_user bigint not null, primary key (fk_user, fk_role))"...

I wonder why the create queries are being executed while running this target, instead only the update queries have to be executed.

(Note: the *.hbm.xml file has some newly inserted column, but this column was not being inserted into the corresponding table).

Atlast I get the message of "Build Successfull".
Can you help me to resolve this issue.

Regards
Ganesan
 
saranga rao
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

if You generate the DDL of then You could have found the sql statments will be drop database with teh create tables .........with the insert and finally it si updata


regards
saranga
 
Ganesan Kaliyaperumal
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Saranga

Thanks for your reply.

Does the SchemaUpdateTask rely on DB driver? I ran the same target in two different servers, in the first server, I can only able to see the alter table... queries are being excecuted, where as in other server I get the create table ... and alter table... queries executed. And more importantly in the second case the newly inserted column was not updated in the DB.

Regards
Ganesan
 
saranga rao
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes

It depends on the DB driver where you have specified in hibernate properties file
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic