HybridProgrammer / grails-dynamic-domain-class-plugin

Automatically exported from code.google.com/p/grails-dynamic-domain-class-plugin
Apache License 2.0
0 stars 0 forks source link

Plugin does not support belongsTo property #7

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Run demo.gsp
2. Add a belongsTo association to the Book class (e.g. static belongsTo = 
[author: Author])
3. Generate the dynamic classes

What is the expected output? What do you see instead?
Expected: Classes would be generated
Actual: An error similar to this is displayed:

Apparent variable 'Author' was found in a static scope but doesn't refer to a 
local variable, static field or class. Possible causes:
You attempted to reference a variable in the binding or an instance variable 
from a static context.
You misspelled a classname or statically imported field. Please check the 
spelling.
You attempted to use a method 'Author' but left out brackets in a place not 
allowed by the grammar.

> What we found so far is that this is somewhat cyclic in nature... meaning, 
Book is looking for the Author class while the Author class is looking for the 
Book class. 

What version of the product are you using? On what operating system?
- Win7
- Grails 1.3.7

Please provide any additional information below.
-

Original issue reported on code.google.com by calli...@gmail.com on 13 Dec 2011 at 10:29

GoogleCodeExporter commented 8 years ago
Thanks for creating this issue, I did some research about it.

Due to the nature of GroovyClassLoader on dynamic compilation which compile one 
class at a time, please see 
http://groovy.codehaus.org/api/groovy/lang/GroovyClassLoader.html#parseClass%28j
ava.lang.String%29

I have no idea how bi-directional association can be supported at the moment.

Original comment by limchee...@vobject.com on 20 Dec 2011 at 9:44

GoogleCodeExporter commented 8 years ago
pleaseif you have any new about this issue

Original comment by aziz.ait...@gmail.com on 28 May 2013 at 4:36

GoogleCodeExporter commented 8 years ago
I was able to make the hasMany/belongsTo work as well as the use of dynamic 
finders.

1. The creation of dynamic domain class will be 2 step compilation. First 
compile two classes without the hasMany/belongsTo relationship. Once done, 
compile again with the hasMany/belongsTo relationship. This is in the 
registerDomainClass method of the DynamicDomainService.

2. After compilation, execute the addDomainClass, registerBeans and 
enhanceDomainClass. This is still under the DynamicDomainService.

3. Add the following in enhanceDomainClass method to enable the use of dynamic 
finders.

HibernatePluginSupport.registerDynamicMethods(dc, fakeGrailsApplication, ctx, 
ctx.sessionFactory)

This is still for further testing. Let me know your feedback on this. Thanks!

Original comment by frnzy2...@gmail.com on 3 Jul 2013 at 9:41