Using an existing database

View: New views
3 Messages — Rating Filter:   Alert me  

Using an existing database

by Esbach, Brandon :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Using an existing database

Hi All,

I'm fairly new to Grails/Hibernate - so hopefully this query isn't too noobish.
Currently I'm in the middle of designing a web client to access a database (previously accessed with a desktop client).  The only catch is, there is significant data already in place that is reliant on pre-existing tools - which means it's highly unlikely that I can restructure the database in the near future.

Outside of changing the *DataSource.groovy files to point to the relevant database (and provide user details), is there anything I would need to be wary of in terms of using the existing database? 

For example, is it likely to cause problems that some "standard" fields are not there (like id, version)?

Thanks!


Re: Using an existing database

by Mano :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Couple of things:

* make sure you comment this line:
String dbCreate = "update" // one of 'create', 'create-drop','update'

You dont want grails altering your schema :)

* Instead of groovy domain objects, create java domain objects with JPA annotations. Refer http://grails.codehaus.org/Hibernate+Integration


Esbach, Brandon wrote:
Hi All,

I'm fairly new to Grails/Hibernate - so hopefully this query isn't too
noobish.
Currently I'm in the middle of designing a web client to access a
database (previously accessed with a desktop client).  The only catch
is, there is significant data already in place that is reliant on
pre-existing tools - which means it's highly unlikely that I can
restructure the database in the near future.

Outside of changing the *DataSource.groovy files to point to the
relevant database (and provide user details), is there anything I would
need to be wary of in terms of using the existing database?  
For example, is it likely to cause problems that some "standard" fields
are not there (like id, version)?

Thanks!

Re: Using an existing database

by Andrew Patzer :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

If you are using Oracle, you may need to set your hibernate_sequence to a high enough value so that future insertions do not produce unique key constraint violations. For instance, if your highest key value in any of your tables is 182974, then the following statement would work for you -

SQL> alter sequence hibernate_sequence increment by 182975 minvalue 0;

Of course, if you're using MySQL, then you don't need to worry about any of this.

Andrew

On 5/31/07, Esbach, Brandon <Esbachb@...> wrote:

Hi All,

I'm fairly new to Grails/Hibernate - so hopefully this query isn't too noobish.
Currently I'm in the middle of designing a web client to access a database (previously accessed with a desktop client).  The only catch is, there is significant data already in place that is reliant on pre-existing tools - which means it's highly unlikely that I can restructure the database in the near future.

Outside of changing the *DataSource.groovy files to point to the relevant database (and provide user details), is there anything I would need to be wary of in terms of using the existing database? 

For example, is it likely to cause problems that some "standard" fields are not there (like id, version)?

Thanks!