I just created a new grails domain class on a project I just started working on. I know the datasources are setup correctly since we already have a bunch of domain classes that are updating to the database just fine.
The error I get:
Caused by BatchUpdateException: ORA-00942: table or view does not exist
I tried running DBMUpdate but that also did not create the table.
Is there something I'm missing with creating domain classes? Do I need to change something in the changelog ? Any advise would be helpful!
The easiest thing would be to add dbCreate = "update"
to your DataSource.groovy. A better thing would be to use the database-migrations plugin for your app.
Regarding manually creating tables, the convention grails following by default is to underscore camelcase. For example, given the following domains:
class User {
String firstName
String lastName
static hasMany = [addresses: Address]
}
class Address {
static belongsTo = [user: User]
}
You would end up with the following tables:
user
---------
id
version
first_name
last_name
---------
address
---------
id
version
user_id
---------
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With