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

How to do SchemaUpdate

 
chandrajeet padhy
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a got a set of normalized db tables which i created thru SchemaExport tool. But I want to add some more new columns and delete some existing columns. I manually edited the mapping files and did SchemaUpdate but nothing got reflected in my DB. Can anybody suggest me how to proceed with?

Paul Could you, give some quick suggestion?
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How are you running this? Through Ant or by the command line? There was an issue with not setting the text="false" property in the Ant task - which seemed to result in no actual commit being done to the DB. It was only a problem with 2.1.2 and got fixed in 2.1.3

If you are not running this through Ant, you might want to set a trace going on your DB and profiling exactly whats happening there - it does sound like nothing is making it as far as the DB.
 
chandrajeet padhy
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Through Ant.
<target name="update-db" depends="make-props" description="Updates the app database.">
<taskdef name="schemaupdate"classname="net.sf.hibernate.tool.hbm2ddl.SchemaUpdateTask"
classpathref="project.class.path"/>
<schemaupdate
properties="config/hibernate.properties"
quiet="true" text="true">
<fileset dir="${build.destdir}">
<include name="**/*.hbm.xml"/>
</fileset>
</schemaupdate>
</target>

But its not taking in DB level to show the changes.
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There's your problem:

text="true" is specifying "text-only" mode. The SchemaUpdate JavaDocs say:

setText
public void setText(boolean text)

Enable "text-only" mode. The schema will not be updated in the database.

Parameters:
text - true to enable text-only mode


Set it to false.

(And probably set quite mode to false too, just for the sake of your sanity till you get this up and running)
[ July 27, 2004: Message edited by: Paul Sturrock ]
 
chandrajeet padhy
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul, I tried making both quite and text attribute to false alternately and to both even. But Its still not doing the job. Is there anyother tweak lies behind this? Could you just tell me the steps how to proceed.
Let me tell, in what way I approached.
1)SchemaExport worked fine with a similar Ant script target to create the DB
2)Created the Ant target for SchemaUpdate as u have seen already.
3)Updated hbm mapping files for deleteing an existing column and adding a new one.
4)ran the Ant target for Update. But there is no affect to DB, but yes the generated persitable classes has the changes as done in mapping xmls.

Where is the loophole pls suggest me.
 
chandrajeet padhy
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul, I tried making both quite and text attribute to false alternately and to both even. But Its still not doing the job. Is there anyother tweak lies behind this? Could you just tell me the steps how to proceed.
Let me tell, in what way I approached.
1)SchemaExport worked fine with a similar Ant script target to create the DB
2)Created the Ant target for SchemaUpdate as u have seen already.
3)Updated hbm mapping files for deleteing an existing column and adding a new one.
4)ran the Ant target for Update. But there is no affect to DB, but yes the generated persitable classes has the changes as done in mapping xmls.

Where is the loophole pls suggest me.
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hmm. Which versions of SchemaUpdate, Hibernate and DB are you using?

Have you run ant with the -verbose flag? Or checked your trace log (or whatever your DB might offer for this level of debugging). You might try (if you can) setting a trace on the DB and watching the activity while running SchemaUpdate.

I can't think of any reason why you might be seeing this behaviour, other than the one I already told you.
 
Andras Soltesz
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It may be a problem that SchemaUpdate doesn't issue a commit when it finishes.

Your database may need a commit after DDL statements (like CREATE TABLE)

You cannot really solve this problem, I have already posted a message on this to the Hibernate JIRA.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic