question on saving the generated classes

80 views
Skip to first unread message

callie

unread,
Oct 6, 2011, 5:12:52 AM10/6/11
to Grails Dynamic Domain Class Plugin
Hi,

This plugin really saved me :) Kudos for the great job!

I was wondering if it was possible to store the generated domain and/
or controller classes? I'm not that privy to the inner workings yet of
Grails so I wasn't sure where to look. Thing is, when I generate a
domain using this then I restart the application (I restart for other
reasons), the associated controller is not yet lost. Then, if I either
restart right away or create another domain before a restart, the
controller of the earlier domain is lost (in short, only the last
generated controller/s is remembered).

However, due to the issue I'm working on, I would need to store a copy
of the controllers... hence, the question: is this possible? Or can
you point me to something I can start with? :)

Thanks again!
callie

Chee Kin Lim

unread,
Oct 6, 2011, 10:55:13 PM10/6/11
to grails-dynamic-do...@googlegroups.com
Hi Callie,

Thanks for trying the plugin.

Yes. I did store the domain class source and reload it on runtime. This is what I did in Grails Form Builder Plugin at http://code.google.com/p/grails-form-builder-plugin/. That's the initial motivation of creating this plugin.

I would like to remind you that the Dynamic Domain Class plugin is barely working solution (which may not scalable at all), it may not work in coming release of Grails 2.0.

Hope this help.

Best regards,
Chee Kin

callie

unread,
Oct 7, 2011, 9:10:50 AM10/7/11
to Grails Dynamic Domain Class Plugin
I understand, nevertheless, thanks for the effort! :)

How about the controller? Is there a way to store this as well? Thanks
again!



On Oct 7, 10:55 am, Chee Kin Lim <limchee...@vobject.com> wrote:
> Hi Callie,
>
> Thanks for trying the plugin.
>
> Yes. I did store the domain class source and reload it on runtime. This is
> what I did in Grails Form Builder Plugin athttp://code.google.com/p/grails-form-builder-plugin/. That's the initial

Chee Kin Lim

unread,
Oct 7, 2011, 9:17:48 AM10/7/11
to grails-dynamic-do...@googlegroups.com
Hi Callie,

Yes, I think you can store controller using the mechanism of dynamic domain class.

But with dynamic controller implementation in the form builder, I don't understand why do you need to do so.

Best regards,
Chee Kin

callie

unread,
Oct 7, 2011, 9:24:44 AM10/7/11
to Grails Dynamic Domain Class Plugin
Hmm.. makes sense, will try that on Monday =)
Need to do this because say I run my app and I generated domain1
(which will trigger the generation of controller1). Then, since I'm
developing, I stopped my app for a host of reasons... Then I restart
my app, controller1 is still present. Then, I generate domain2
(controller2 will get generated). Then I stopped my app again... When
I restart my app, only controller2 is listed, controller1 is no longer
there (based on the demo you provided).

I'll check out what you've suggested soon and will update you :)

Thanks!


On Oct 7, 9:17 pm, Chee Kin Lim <limchee...@vobject.com> wrote:
> Hi Callie,
>

callie

unread,
Nov 23, 2011, 1:20:21 AM11/23/11
to Grails Dynamic Domain Class Plugin
Hello again :)

I would just like to revisit this topic again if you don't mind.

I've been having problems with solving this particular scenario: You
run the app, create your dynamic domains. However, the application is
turned off/shut down. Once the app restarts, since there are no
physical files representing the domains and the dynamic classes are
stored "in memory", the dynamic domain classes are lost (evident when
I get the list of domain classes registered to grailsApplication). So,
I need a way to reload them upon the app's startup sequence.

Now, as a workaround I found 2 possible approaches:
1. I decided to store the actual string containing the domain classes
and recompile/reload them. However, if, let's say, we have 1,000
domain classes and you decide to recompile/reload them, that's pretty
expensive; what more if you have 1 million. Also, if there are
dependencies (e.g. 1 domain class is a "child" of another domain
class, the child must be compiled first, etc.), then I would need to
resolve those first :(

2. Save the domain's class file and reload when the app starts.
However, although I think that this is more ideal, I'm running into a
lot of trouble when I try using the domain's properties (e.g. dynamic
functions)... even something as simple as .save() would lead to errors
concerning "entity not found" etc. (hinting about probable hibernate
issues?).

Now, I'm kinda lost on how to proceed... can you suggest where I can
go from here?

Thanks and regards,
callie

Chee Kin Lim

unread,
Nov 23, 2011, 1:44:29 AM11/23/11
to grails-dynamic-do...@googlegroups.com
Hi Callie,

As you said, if your application have millions dynamic domain classes, you may run into scalability issue.

My solution is load all dynamic domain classes which stored in database upon application start-up. If there is any update or new domain classes created subsequently, it will load by a scheduler that run in background periodically.

You can see the application of idea above in the Grails Form Builder plugin at http://code.google.com/p/grails-form-builder-plugin/

Hope this help!

Best regards,
Chee Kin

callie

unread,
Dec 13, 2011, 12:37:15 AM12/13/11
to Grails Dynamic Domain Class Plugin
Thanks, that helped!

Is belongsTo supported? I noticed that when I tried the demo.gsp with
1 class having the hasMany mapping and the other has belongsTo, an
error was thrown. We seem to need the belongsTo functionality at this
point so we were wondering if there's a way to get the parent class
without the belongsTo association.

Thanks!


On Nov 23, 2:44 pm, Chee Kin Lim <limchee...@vobject.com> wrote:
> Hi Callie,
>
> As you said, if your application have millions dynamic domain classes, you
> may run into scalability issue.
>
> My solution is load all dynamic domain classes which stored in database
> upon application start-up. If there is any update or new domain classes
> created subsequently, it will load by a scheduler that run in background
> periodically.
>
> You can see the application of idea above in the Grails Form Builder plugin

> athttp://code.google.com/p/grails-form-builder-plugin/

Chee Kin Lim

unread,
Dec 13, 2011, 3:00:27 AM12/13/11
to grails-dynamic-do...@googlegroups.com
You're welcome!

Thanks for reporting this issue, please create an issue at http://code.google.com/p/grails-dynamic-domain-class-plugin/issues/list

Best regards,
Chee Kin

callie

unread,
Dec 13, 2011, 5:20:31 AM12/13/11
to Grails Dynamic Domain Class Plugin
Thanks, will do! :)


On Dec 13, 4:00 pm, Chee Kin Lim <limchee...@vobject.com> wrote:
> You're welcome!
>

> Thanks for reporting this issue, please create an issue athttp://code.google.com/p/grails-dynamic-domain-class-plugin/issues/list

Reply all
Reply to author
Forward
0 new messages