• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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
 
You get good luck from rubbing the belly of a tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic