Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Override @GeneratedValue annotation with AspectJ

Hi Ricardo,

> These rules can't override the behaviour of the @GeneratedValue annotation with the attributes that I redefined.
>
> What I'm doing wrong?How can I override the behaviour/definition of @GeneratedValue with Aspects?
> is the preference wrong defined? Exists another way to override a sequence to an identifier with aspects?

You aren't doing anything wrong.  What you are trying to do is not
supported at the moment.  However, I've been having a few chats with
users lately and might be doing something in this area soon.  The use
case I have seen recently is someone wishing to augment the annotation
by providing values that were not specified in the annotation that
already exists on the target.  I see two use cases arising from your
description too:

a) replacing the annotation that already exists on the target with the
declared one
b) specifying precedence when there are multiple that might apply to a target

I've raised https://bugs.eclipse.org/bugs/show_bug.cgi?id=313026 to
track these 3 use cases.

cheers
Andy


On 13 May 2010 23:44, ricardo garcia fernandez <alcoholitro@xxxxxxxxx> wrote:
> Hi everyone I'm new here! And need to solve a doubt with aspectj.
>
> Here is my "problem":
>
> Override @GeneratedValue annotation with AspectJ
>
> Override annotated values with aspectj file
>
> Hi!
>
> I'm generating an annotation to set a defined sequenceValue to an id field
> for an Entity in Postgres DDBB.
>
> I've been looking in AspectJ documentation:
>
>   -
> [url=http://www.eclipse.org/aspectj/doc/released/adk15notebook/annotations-decp.html#declare-precedence]
> http://www.eclipse.org/aspectj/doc/released/adk15notebook/an
> notations-decp.html#declare-precedence[/url]
>
> to apply precende rules between aspects.
>
> I've created a new aspect applying the precedence rules and adding
> annotations to fields:
> [code]
>
> privileged aspect Person_Company_generated_id {
>
>     declare precedence: Person_Company_generated_id, Person_Roo_Entity;
>
>     declare @field: *
> org.company.test.generated.id.sequence.domain.Person.id :
> @GeneratedValue(strategy=GenerationType.SEQUENCE, generator="PersonSeq");
>
>     declare @field: *
> org.company.test.generated.id.sequence.domain.Person.id :
> @SequenceGenerator(name="PersonSeq",sequenceName="PERSON_SEQ",
> allocationSize=500, initialValue=601);
> }
> [/code]
>
> The aspect generated [i]Person_Roo_Entity[/i] defines the annotation in the
> id attribute:
> [code]
>      @id
>      @GeneratedValue(strategy = GenerationType.AUTO)
> [/code]
>
> This only works if I remove the @GeneratedValue annotation from
> [i]Person_Roo_Entity[/i].
>
> These rules can't override the behaviour of the @GeneratedValue annotation
> with the attributes that I redefined.
>
> What I'm doing wrong?How can I override the behaviour/definition of
> @GeneratedValue with Aspects? is the preference wrong defined? Exists
> another way to override a sequence to an identifier with aspects?
>
> Scenario:
> * JDK-1.5.0_07
> * PostgreSQL 8.3.8
> * AspectJ 1.6.9.BUILD-SNAPSHOT
>
> Thanks for your time.
>
> Best regards...
>
> I've posted into:
> http://www.eclipse.org/forums/index.php?t=msg&th=167973&start=0&SQ=fb4f3046ec925ddb4a025fa9144c6c4a&;
>
>
> --
> ---
> Ricardo García Fernández
>
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
>


Back to the top