-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 
Author Message
 Post subject: Using SchemaUpdate to generate DDL only
PostPosted: Wed May 24, 2006 12:33 pm 
Newbie

Joined: Wed May 24, 2006 12:22 pm
Posts: 2
Im trying to update my Oracle 10g instance schema by running SchemaUpdate from the command line. But the DBAs arent impressed and SchemaUpdate fails due to lack of priviliges.

So I want to use SchemaUpdate to only generate the DDL for me for the diff b/w my XML schema and actual DB schema. Then I intend to run those statements by directly logging on to the DB and I shud I have an up to date schema.

For SchemaExport, there is a --text flag which only generates DDL but doesnt try to connect and do the update itself. Is there something similar for SchemaUpdate?

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 24, 2006 1:14 pm 
Regular
Regular

Joined: Mon May 22, 2006 2:30 pm
Posts: 74
It should support that. If you check the Hibernate API doc for the SchemaUpdate class, the execute() method takes a boolean to indicate whether or not an actual update should be performed. I don't know what you need to do on the command line to set the value for that boolean to false.


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 24, 2006 1:21 pm 
Regular
Regular

Joined: Mon May 22, 2006 2:30 pm
Posts: 74
A quick search via Google located the following info:

--quiet Echo the script to the console

--properties= filename.properties Specify the hibernate.properties file

--config= filename.cfg.xml Specify the hibernate.cfg.xml file

--text Do not execute the update

--naming=fully.qualified.class.name Specify the naming policy to use (Hibernate ships with net.sf.hibernate.cfg.Default NamingStrategy (prefers mixed case) and net.sf.hibernate.cfg.
ImprovedNamingStrategy (prefers underscores).


So, yes. Apparently it supports the same command line option.


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 24, 2006 2:03 pm 
Newbie

Joined: Wed May 24, 2006 12:22 pm
Posts: 2
I thought --text should work too. But when I run the command with that flag, I get an error which seems like the tool is actually trying to run some updates. Its throwing a ORA-01031 which is generally thrown when you are trying to create something somewhere you arent permitted to. And the part of the stack trace in bold may indicate that too, Im not sure.

Thanks.



2006-05-23 09:12:24,451857 [main] ERROR org.hibernate.tool.hbm2ddl.SchemaUpdate : could not complete schema update
org.hibernate.exception.SQLGrammarException: could not get table metadata: agent
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:65)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:29)
at org.hibernate.tool.hbm2ddl.DatabaseMetadata.getTableMetadata(DatabaseMetadata.java:100)
at org.hibernate.cfg.Configuration.generateSchemaUpdateScript(Configuration.java:838)
at org.hibernate.tool.hbm2ddl.SchemaUpdate.execute(SchemaUpdate.java:144)
at org.hibernate.tool.hbm2ddl.SchemaUpdate.main(SchemaUpdate.java:100)
Caused by: java.sql.SQLException: ORA-01031: insufficient privileges

at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:289)
at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:582)
at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1986)
at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteFetch(TTC7Protocol.java:1144)
at oracle.jdbc.driver.OracleStatement.executeNonQuery(OracleStatement.java:2152)
at oracle.jdbc.driver.OracleStatement.doExecuteOther(OracleStatement.java:2035)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:2876)
at oracle.jdbc.driver.OracleStatement.executeUpdate(OracleStatement.java:878)
at oracle.jdbc.OracleDatabaseMetaData.getIndexInfo(OracleDatabaseMetaData.java:3255)
at org.hibernate.tool.hbm2ddl.TableMetadata.initIndexes(TableMetadata.java:141)
at org.hibernate.tool.hbm2ddl.TableMetadata.<init>(TableMetadata.java:36)
at org.hibernate.tool.hbm2ddl.DatabaseMetadata.getTableMetadata(DatabaseMetadata.java:85)


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 24, 2006 2:34 pm 
Regular
Regular

Joined: Mon May 22, 2006 2:30 pm
Posts: 74
I see what you mean. It's hard to say exactly what it's doing. Perhaps it has to run through that process as if it were updating the schema, in order to generate the new schema definition, but does not actually commit the changes at the end. The Oracle SchemaUpdate class may have similar behaviour to the Hibernate SchemaUpdate, in that it has an option to not actually perform the update. But you would still need permissions as if it were going to. I'm speculating at this point though. You might have to create a test schema of your own that you can experiment with to determine what is really happening.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.