-->
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.  [ 3 posts ] 
Author Message
 Post subject: Check for existing schema? Create but don't drop?
PostPosted: Fri Dec 29, 2006 10:02 am 
Beginner
Beginner

Joined: Sat Dec 16, 2006 1:52 pm
Posts: 40
I am using the SchemaExport to create my schema at runtime. Is it possible to create a schema without dropping the existing schema?

It seems as if the schemas match, then it will not drop the existing schema. But just now, when my schemas did not match, it seems to have dropped the existing schema and recreated a new one.

I want to create if there is none, but if there is existing schema, it should abort. Perhaps there is a simple way to check if a schema exists? And I mean exists, not that its completely valid, just that there is _any_ schema present.

Thanks!


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 29, 2006 10:28 am 
Expert
Expert

Joined: Tue Dec 28, 2004 7:02 am
Posts: 573
Location: Toulouse, France
I'm not sure it's possible to tell SchemaUpdate to not execute if the given schema is already present.

But maybe you could do it by yourself, doing some jdbc before calling SchemaUpdate to verify it's possible, then create a patch for it?

Something like:
Code:
if(!schemaAlreadyExists(jdbcConnection, "theSchemaName"))
{
new SchemaUpdate()...execute(...);
}

_________________
Baptiste
PS : please don't forget to give credits below if you found this answer useful :)


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 22, 2007 2:46 pm 
Beginner
Beginner

Joined: Sat Dec 16, 2006 1:52 pm
Posts: 40
That looks interesting. Right now I get a JDBC conneciton and start checking for tables. Does hibernate give a schema or catalog name or something I can check for? Can I control that name? It would be much easier to check for that then to start checking for table names.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.