Renaming model beans

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

Renaming model beans

Jonathan Carlson
Is there a special way to rename and delete model beans?  I manually renamed òne (and the controller, BTW) but the run-app command still thought there the old class name was there.

I tried deleting it out of the tmp/war/WEB-INF/grails-app/* folders but then I ran into issues with config files looking for the class too so I gave up and decided to generate a clean app and copy my model beans over.   I'm getting further although I'm still not successful in getting it to run yet.  I'm sorry for all these errors, but I'm still new to Grails and if I'm just doing stupid typing errors then the error messages should be more explanatory.  (I had the same complaints about Groovy a year ago, but I stuck it out and their error messages are getting much better now)

Here's my error:
   [groovy] Caused by: java.lang.IllegalArgumentException: id to load is required for loading
   [groovy]     at org.hibernate.event.LoadEvent.<init>(LoadEvent.java:51)
   [groovy]     at org.hibernate.event.LoadEvent.<init>(LoadEvent.java:33)
   [groovy]     at org.hibernate.impl.SessionImpl.get(SessionImpl.java:825)
   [groovy]     at org.hibernate.impl.SessionImpl.get(SessionImpl.java:821)
   [groovy]     at org.springframework.orm.hibernate3.HibernateTemplate$1.doInHibernate(HibernateTemplate.java:451)
   [groovy]     at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:365)
   [groovy]     at org.springframework.orm.hibernate3.HibernateTemplate.get(HibernateTemplate.java:445)
   [groovy]     at org.springframework.orm.hibernate3.HibernateTemplate.get(HibernateTemplate.java:439)
   [groovy]     at org.codehaus.groovy.grails.orm.hibernate.metaclass.SavePersistentMethod.doInvokeInternal(SavePersistentMethod.java:105)
   [groovy]     at org.codehaus.groovy.grails.orm.hibernate.metaclass.AbstractDynamicPersistentMethod.invoke(AbstractDynamicPersistentMethod
.java:49)
   [groovy]     at org.codehaus.groovy.grails.commons.metaclass.AbstractDynamicMethods.invokeMethod(AbstractDynamicMethods.java:136)
   [groovy]     at org.codehaus.groovy.grails.commons.metaclass.DelegatingMetaClass.invokeMethod(DelegatingMetaClass.java:50)
   [groovy]     at org.codehaus.groovy.runtime.Invoker.invokeMethod(Invoker.java:156)
   [groovy]     at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:104)
   [groovy]     at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethod(ScriptBytecodeAdapter.java:85)
   [groovy]     at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeNoArgumentsMethod(ScriptBytecodeAdapter.java:175)
   [groovy]     at ApplicationBootStrap$_closure1.doCall(ApplicationBootStrap:12)
   [groovy]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   [groovy]     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   [groovy]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   [groovy]     at java.lang.reflect.Method.invoke(Method.java:324)
   [groovy]     at org.codehaus.groovy.runtime.ReflectionMetaMethod.invoke(ReflectionMetaMethod.java:67)
   [groovy]     at org.codehaus.groovy.runtime.MetaClassHelper.doMethodInvoke(MetaClassHelper.java:636)
   [groovy]     ... 48 more
   [groovy] statements executed successfully

I trimmed back my classes to be more basic:

class Message {
  @Property Long id
  @Property Long version

  @Property MessageThread messageThread = new MessageThread()
  @Property String userName = ""
  @Property Date date = new Date()
  @Property String body = ""
}

class MessageThread {
  @Property Long id
  @Property Long version
 
  Map relatesToMany = [messages : Message.class]
 
  @Property String title = ""
  @Property Set messages = new HashSet()
}







______________________________________________________________________
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

Katun Corporation -- www.katun.com
_____________________________________________________________________
Reply | Threaded
Open this post in threaded view
|

Re: Renaming model beans

graemer
On 3/20/06, Jonathan Carlson <[hidden email]> wrote:
> Is there a special way to rename and delete model beans?  I manually renamed òne (and the controller, BTW) but the run-app command still thought there the old class name was there.
>
> I tried deleting it out of the tmp/war/WEB-INF/grails-app/* folders but then I ran into issues with config files looking for the class too so I gave up and decided to generate a clean app and copy my model beans over.   I'm getting further although I'm still not
successful in getting it to run yet.  I'm sorry for all these errors,
but I'm still new to Grails and if I'm just doing stupid typing errors
then the error messages should be more explanatory.  (I had the same
complaints about Groovy a year ago, but I stuck it out and their error
messages are getting much better now)
>
Config files? What config files? Grails' configuration is done at
runtime. deleting the tmp directory should do it or doing:

grails clean run-app

Graeme

> Here's my error:
>    [groovy] Caused by: java.lang.IllegalArgumentException: id to load is required for loading
>    [groovy]     at org.hibernate.event.LoadEvent.<init>(LoadEvent.java:51)
>    [groovy]     at org.hibernate.event.LoadEvent.<init>(LoadEvent.java:33)
>    [groovy]     at org.hibernate.impl.SessionImpl.get(SessionImpl.java:825)
>    [groovy]     at org.hibernate.impl.SessionImpl.get(SessionImpl.java:821)
>    [groovy]     at org.springframework.orm.hibernate3.HibernateTemplate$1.doInHibernate(HibernateTemplate.java:451)
>    [groovy]     at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:365)
>    [groovy]     at org.springframework.orm.hibernate3.HibernateTemplate.get(HibernateTemplate.java:445)
>    [groovy]     at org.springframework.orm.hibernate3.HibernateTemplate.get(HibernateTemplate.java:439)
>    [groovy]     at org.codehaus.groovy.grails.orm.hibernate.metaclass.SavePersistentMethod.doInvokeInternal(SavePersistentMethod.java:105)
>    [groovy]     at org.codehaus.groovy.grails.orm.hibernate.metaclass.AbstractDynamicPersistentMethod.invoke(AbstractDynamicPersistentMethod
> .java:49)
>    [groovy]     at org.codehaus.groovy.grails.commons.metaclass.AbstractDynamicMethods.invokeMethod(AbstractDynamicMethods.java:136)
>    [groovy]     at org.codehaus.groovy.grails.commons.metaclass.DelegatingMetaClass.invokeMethod(DelegatingMetaClass.java:50)
>    [groovy]     at org.codehaus.groovy.runtime.Invoker.invokeMethod(Invoker.java:156)
>    [groovy]     at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:104)
>    [groovy]     at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethod(ScriptBytecodeAdapter.java:85)
>    [groovy]     at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeNoArgumentsMethod(ScriptBytecodeAdapter.java:175)
>    [groovy]     at ApplicationBootStrap$_closure1.doCall(ApplicationBootStrap:12)
>    [groovy]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>    [groovy]     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>    [groovy]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>    [groovy]     at java.lang.reflect.Method.invoke(Method.java:324)
>    [groovy]     at org.codehaus.groovy.runtime.ReflectionMetaMethod.invoke(ReflectionMetaMethod.java:67)
>    [groovy]     at org.codehaus.groovy.runtime.MetaClassHelper.doMethodInvoke(MetaClassHelper.java:636)
>    [groovy]     ... 48 more
>    [groovy] statements executed successfully
>
> I trimmed back my classes to be more basic:
>
> class Message {
>   @Property Long id
>   @Property Long version
>
>   @Property MessageThread messageThread = new MessageThread()
>   @Property String userName = ""
>   @Property Date date = new Date()
>   @Property String body = ""
> }
>
> class MessageThread {
>   @Property Long id
>   @Property Long version
>
>   Map relatesToMany = [messages : Message.class]
>
>   @Property String title = ""
>   @Property Set messages = new HashSet()
> }
>
>
>
>
>
>
>
> ______________________________________________________________________
> This email and any files transmitted with it are confidential and
> intended solely for the use of the individual or entity to whom they
> are addressed. If you have received this email in error please notify
> the system manager.
>
> Katun Corporation -- www.katun.com
> _____________________________________________________________________
>
Reply | Threaded
Open this post in threaded view
|

Re: Renaming model beans

Jonathan Carlson
In reply to this post by Jonathan Carlson
Doh.  Thanks for the "clean" target idea.  I knew there must be something like that.  I think it should be included in the usages description when you type grails without a target.  (Maybe it's already documented elsewhere and I just didn't see it :-)

- Jonathan

>>> [hidden email] 2006-03-20 2:54:23 PM >>>
On 3/20/06, Jonathan Carlson <[hidden email]> wrote:
> Is there a special way to rename and delete model beans?  I manually renamed òne (and the controller, BTW) but the run-app command still thought there the old class name was there.
>
> I tried deleting it out of the tmp/war/WEB-INF/grails-app/* folders but then I ran into issues with config files looking for the class too so I gave up and decided to generate a clean app and copy my model beans over.   I'm getting further although I'm still not
successful in getting it to run yet.  I'm sorry for all these errors,
but I'm still new to Grails and if I'm just doing stupid typing errors
then the error messages should be more explanatory.  (I had the same
complaints about Groovy a year ago, but I stuck it out and their error
messages are getting much better now)
>
Config files? What config files? Grails' configuration is done at
runtime. deleting the tmp directory should do it or doing:

grails clean run-app

Graeme

> Here's my error:
>    [groovy] Caused by: java.lang.IllegalArgumentException: id to load is required for loading
>    [groovy]     at org.hibernate.event.LoadEvent.<init>(LoadEvent.java:51)
>    [groovy]     at org.hibernate.event.LoadEvent.<init>(LoadEvent.java:33)
>    [groovy]     at org.hibernate.impl.SessionImpl.get(SessionImpl.java:825)
>    [groovy]     at org.hibernate.impl.SessionImpl.get(SessionImpl.java:821)
>    [groovy]     at org.springframework.orm.hibernate3.HibernateTemplate$1.doInHibernate(HibernateTemplate.java:451)
>    [groovy]     at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:365)
>    [groovy]     at org.springframework.orm.hibernate3.HibernateTemplate.get(HibernateTemplate.java:445)
>    [groovy]     at org.springframework.orm.hibernate3.HibernateTemplate.get(HibernateTemplate.java:439)
>    [groovy]     at org.codehaus.groovy.grails.orm.hibernate.metaclass.SavePersistentMethod.doInvokeInternal(SavePersistentMethod.java:105)
>    [groovy]     at org.codehaus.groovy.grails.orm.hibernate.metaclass.AbstractDynamicPersistentMethod.invoke(AbstractDynamicPersistentMethod
> .java:49)
>    [groovy]     at org.codehaus.groovy.grails.commons.metaclass.AbstractDynamicMethods.invokeMethod(AbstractDynamicMethods.java:136)
>    [groovy]     at org.codehaus.groovy.grails.commons.metaclass.DelegatingMetaClass.invokeMethod(DelegatingMetaClass.java:50)
>    [groovy]     at org.codehaus.groovy.runtime.Invoker.invokeMethod(Invoker.java:156)
>    [groovy]     at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:104)
>    [groovy]     at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethod(ScriptBytecodeAdapter.java:85)
>    [groovy]     at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeNoArgumentsMethod(ScriptBytecodeAdapter.java:175)
>    [groovy]     at ApplicationBootStrap$_closure1.doCall(ApplicationBootStrap:12)
>    [groovy]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>    [groovy]     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>    [groovy]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>    [groovy]     at java.lang.reflect.Method.invoke(Method.java:324)
>    [groovy]     at org.codehaus.groovy.runtime.ReflectionMetaMethod.invoke(ReflectionMetaMethod.java:67)
>    [groovy]     at org.codehaus.groovy.runtime.MetaClassHelper.doMethodInvoke(MetaClassHelper.java:636)
>    [groovy]     ... 48 more
>    [groovy] statements executed successfully
>
> I trimmed back my classes to be more basic:
>
> class Message {
>   @Property Long id
>   @Property Long version
>
>   @Property MessageThread messageThread = new MessageThread()
>   @Property String userName = ""
>   @Property Date date = new Date()
>   @Property String body = ""
> }
>
> class MessageThread {
>   @Property Long id
>   @Property Long version
>
>   Map relatesToMany = [messages : Message.class]
>
>   @Property String title = ""
>   @Property Set messages = new HashSet()
> }
>
>
>
>
>
>
>
> ______________________________________________________________________
> This email and any files transmitted with it are confidential and
> intended solely for the use of the individual or entity to whom they
> are addressed. If you have received this email in error please notify
> the system manager.
>
> Katun Corporation -- www.katun.com
> _____________________________________________________________________
>

______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
______________________________________________________________________

______________________________________________________________________
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

Katun Corporation -- www.katun.com
_____________________________________________________________________