How to create a domain object "view" in Grails

I am trying to adapt an obsolete database to a grails application, and I'm not sure how to do this on grails. I have a huge table (with colA, colB, ..., colZ columns) that I only want to display some of them as fields (for example, colA, colC, colE), like the database view, this domain class It is intended for reading - only therefore there would be no problems not to carry out operations of saving, updating and deleting.

How do I create a domain class?

EDIT

I need to adapt the query to a domain object, this query contains many groups of expressions (max, min, count, etc.), and I would like to adapt this query so that every time I call DomainObj.list () Grails will execute this request and upload all the data from the database to the GORM proxy server.

+4
source share
1 answer

If it is read-only, just create a domain object containing the fields of interest to you. This should not be a problem.

Remember, however, that GORM will create the default version column, but this can be disabled:

static mapping = { table 'people' version false } 
+4
source

Source: https://habr.com/ru/post/1379987/


All Articles