• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

SchemaUpdateTask executes create query

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes

It depends on the DB driver where you have specified in hibernate properties file
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic