Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Overriding an AspectJ method in a Roo Project

You might also be interested in voting for https://jira.springsource.org/browse/DATAJPA-209 which is related to the problem you're describing.

-matthew

On Wed, Jun 20, 2012 at 10:04 AM, Andy Clement <andrew.clement@xxxxxxxxx> wrote:
Hi,

I fired your question off to the Roo team and got this response:
===
Roo metadata classes check for the existence of methods in the
"governor" (.java file) that are destined to be written to an ITD and
prevents these methods from going in the ITDs if they are there in the
java class. However, this check is not happening with the finder
methods. Finder methods are different in that the method name is
dynamically built up using the finder fields and the find operation
required (eg findPhotosBySlugLikeAndBudgetLikeAndProjectLikeAndProjectStatusLike).
I don't believe in this case the methods are checked in the .java
class first as there can be an unknown number of methods generated.

I can play around with this, but my first suggestion would be to
push-in the method to the .java class to be able to tailor it and also
remove the finder name from the "finders" attribute of the
@RooJpaActiveRecord annotation, to prevent its generation in the ITD.
===

I hope that is useful?  You might get faster responses directly using
the Roo forum:
http://forum.springsource.org/forumdisplay.php?67-Roo

cheers
Andy

On 19 June 2012 08:20,  <phiroc@xxxxxxx> wrote:
>
>
>
>
> Hello,
>
> I have just generated a web application with Spring Roo and would like to override a method which lets users search records
> in a photo database.
>
> Here's the Roo-generated Photo_Roo_Finder.aj code:
>
> -----------------------------------
>
> // WARNING: DO NOT EDIT THIS FILE. THIS FILE IS MANAGED BY SPRING ROO.
> // You may push code into the target .java compilation unit if you wish to edit any member(s).
>
> privileged aspect Photo_Roo_Finder {
>
> public static TypedQuery<Photo> Photo.findPhotosBySlugLikeAndBudgetLikeAndProjectLikeAndProjectStatusLike(
> String slug, String budget, String project, String projectStatus) {
>
> if (slug == null || slug.length() == 0) throw new IllegalArgumentException("The slug argument is required);
> ...
>
> -----------------------------------------------
>
> My problem with this method is that it does not let users leave some fields empty.
>
> If I go into the Photo.java class, and rewrite the above method, Eclipse tells me that it already exists (ie, in the
> .aj file).
>
> If, on the other hand, I rename it in the Photo class, as follows
>
> ---------------------------------------------------
>
> ...
> @RooJpaActiveRecord(finders = { "findPhotosBySlugLikeAndBudgetLikeAndProjectLikeAndProjectStatusLike2" })
> ...
>
>
> public static TypedQuery<Photo> Photo.findPhotosBySlugLikeAndBudgetLikeAndProjectLikeAndProjectStatusLike2(..
>
> String slug2 = "";
>
> if (slug == null) || slug.length == 0) {
> slug2 = "";
>
> } else {
> slug2 = slug;
>
> }
> // Do a search with slug2 as value.
>
> --------------------------------------
>
> The application, when run, crashes with an internal error:
>
> -----------------------------
>
> or.apache.tiles.impl.CannotRenderException: JSP Exception including path '/WEB-INF/views/photos/findPhotosBySlugLikeAndBudgetLikeAndProjectLikeAndProjectStatusLike.jspx'
>
>
> where findPhotos....jspx is some kind of dynamically-generated jspx file (ie, it's not visible in the Eclipse Project).
>
> -----------------------------
>
> So how can I "override" the "findPhotosBySlugLikeAndBudgetLikeAndProjectLikeAndProjectStatusLike" method
> in the Photo class?
>
> Any help with the above issue would be much appreciated.
>
> Philroc
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users



--
mailto:matthew@xxxxxxxxxxxxxxx 
skype:matthewadams12
googletalk:matthew@xxxxxxxxxxxxxxx
http://matthewadams.me
http://www.linkedin.com/in/matthewadams


Back to the top