Reputation: 151
I tried to create domain class from database view. But when I try run project I see:
Error | 2016-01-19 17:15:00,525 [Thread-11] ERROR spi.SqlExceptionHelper - ORA- 01702: a view is not appropriate here Error | 2016-01-19 17:15:00,526 [Thread-11] ERROR hbm2ddl.SchemaUpdate - HHH000299: Could not complete schema update
my class:
class Branch {
int id
String name
static mapping = {
table 'smart_branch'
version false
cache: 'read-only'
id column: 'id'
name column: 'name'
}
static constraints = {
}
}
I use oracle 10g and in the view I use link to another oracle database.
view:
create or replace view branch (id, name) as (select id, convert(zzz.convert2@b(name)) from zzz.branch@db emp)
Upvotes: 1
Views: 283
Reputation: 2188
Domain class is an entity, a table inside db on which you can run DML queries. Views are mainly used for only fetching the data and not modifying it.
You should also not try that. Also if you are using Hibernate to generate schema for you, then you can't have a table and a view with same name. You would have to either set dbCreate
mode to none
in your DataSource.groovy
or remove the mapping of the doamin from db using mapWith
property.
But if you still want to have a Doamin class that fetches data from a view then you can look into this answer.
Upvotes: 1