Does domain object has to map a table?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Does domain object has to map a table?

GrailsNewbie
Hello,

If my grails service class returns a result set of type cursor (multiple rows) can I map them to domain? in other words can I use domain as model to map a row set . For example if I have a Person table with columns Id, First Name, Last Name, Address etc. and my result set returns me rows with only columns FirstName and LastName . Can I create a domain called Person and not map it directly to table Person instead use it a plain model?

Thanks.

--
You received this message because you are subscribed to the Google Groups "Grails Dev Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/grails-dev-discuss/ca8d0a7b-8045-497e-ab27-3921b318ce3f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Does domain object has to map a table?

Jeff Brown
On September 29, 2016 at 5:17:11 PM, GrailsNewbie
([hidden email]) wrote:
> Hello,
>
> If my grails service class returns a result set of type cursor (multiple
> rows) can I map them to domain? in other words can I use domain as model to
> map a row set . For example if I have a Person table with columns Id, First
> Name, Last Name, Address etc. and my result set returns me rows with only
> columns FirstName and LastName . Can I create a domain called Person and
> not map it directly to table Person instead use it a plain model?
>

You can’t create a domain lass and not map it to a table.  Part of the
definition of a domain class is that it is mapped to a table (assuming
you are using Hibernate GORM).

You could create a class that isn’t a domain class and use that for
what you are describing.  You should define that class under
src/groovy/ for Grails 2 or src/main/groovy for Grails 3.




JSB
--
Jeff Scott Brown
OCI Grails Practice Lead
Principal Software Engineer

Autism Strikes 1 in 166
Find The Cause ~ Find The Cure
http://www.autismspeaks.org/

--
You received this message because you are subscribed to the Google Groups "Grails Dev Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/grails-dev-discuss/CAEfmkrjTrRuCnX5ckrM7Y7RJvB2paNem8AHZDbm2zRUBR0PVOA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Does domain object has to map a table?

Jeff Brown


On September 30, 2016 at 3:49:43 PM, Jeff Brown ([hidden email]) wrote:

>  
>  
> On September 29, 2016 at 5:17:11 PM, GrailsNewbie ([hidden email]) wrote:  
> > Hello,
> >
> > If my grails service class returns a result set of type cursor (multiple
> > rows) can I map them to domain? in other words can I use domain as model to
> > map a row set . For example if I have a Person table with columns Id, First
> > Name, Last Name, Address etc. and my result set returns me rows with only
> > columns FirstName and LastName . Can I create a domain called Person and
> > not map it directly to table Person instead use it a plain model?
> >
>  
> You can’t create a domain lass and not map it to a table. Part of the definition of a domain  
> class is that it is mapped to a table (assuming you are using Hibernate GORM).
>  
> You could create a class that isn’t a domain class and use that for what you are describing.  
> You should define that class under src/groovy/ for Grails 2 or src/main/groovy for Grails  
> 3.
>  

Strictly speaking that isn’t really true.  You could use…

   static mapWith = “none"

But it isn’t clear why you want the thing to be a domain class to begin with.



JSB
--
Jeff Scott Brown
OCI Grails Practice Lead
Principal Software Engineer  

Autism Strikes 1 in 166
Find The Cause ~ Find The Cure
http://www.autismspeaks.org/

--
You received this message because you are subscribed to the Google Groups "Grails Dev Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/grails-dev-discuss/etPan.57eed027.37febe4e.15cd3%40ociweb.com.
For more options, visit https://groups.google.com/d/optout.
Loading...