On 7/10/06, Svilen Ivanov <[EMAIL PROTECTED]> wrote: > I'm trying to rename auto generated relationship to a more convenient > name.
Before I continue with my other suggestions, remember that you can do this by making your own custom ConventionManager subclass so that the auto-generated names suit your needs to begin with and don't have to be modified after the fact. > It seems adding new relationship doesn't create the new methods Right. Adding or modifying columns or relationships does not automatically cause any methods to be created. You're merely modifying the metadata. The method creation process reads the metadata, but it is a separate task controlled by its own methods. Methods are created during calls to initialize() or auto_initialize(). There re also explicit make_*_methods() methods. Finally, each column and relationship has its own make_methods() call used to make methods just for that particular piece of metadata. > I tried manually calling make_methods after renaming the relationship but but > I got this error: > > Error: Cannot create method My::Category::add_categories - method > already exists at > /usr/lib/perl5/site_perl/5.8.4/Rose/DB/Object/Metadata/MethodMaker.pm > line 420 If you explicitly call make_methods() after previously calling initialize() or auto_initialize() (or an earlier call to make_methods()), then you must decide how you want the call to behave. Should it override an existing methods with the same name? Should it preserve existing methods with the same name? Or (the default) should it cause a fatal error if a method with the same name already exists? This behavior is controlled by arguments to the (auto_)?initialize() and make_methods() methods. See the documentation for the respective methods for details. > (a) is there a simpler way for renaming a relationship w/ building new methods > (b) if not (a), how can I make relationship to create methods with > different name As mentioned earlier, creating a custom convention manager is probably the "cleanest" solution from the perspective of the code that appears in the individual classes. It may be a bit of a slog to get your custom CM to do exactly what you want, but it may be worth it in the long run if you are auto-generating many classes. Failing that, you can modify the metadata and re-create the associated methods after the fact as described above. You may want to use the metadata object's post_init_hook to do this, since it can be set from the Loader. -John ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ Rose-db-object mailing list Rose-db-object@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rose-db-object