0

I've been using Spring Roo for quite some time now. I really like how it takes the mundane programming away and allows you to really focus on the logic of your app. However I've recently found myself fighting with the runtime because it keeps updating my JPA annotations and removing the attribute names.

I'm calling a stored procedure where I calculate a derived value (the distance to a venue from users current location) and attempt to store it in a JPA record object. I have been able to get the code to work successfully as described in this question SqlResultSetMapping columns as and entities

I managed to do this by disabling the Spring Roo shell and then manually updating the annotation before recompiling my project.

However when I'm writing this logic in the spring source tool suite running a Roo shell, the Roo runtime always updates the annotation from this:

@SqlResultSetMapping(name = "findVenuesByDistanceMapping", entities = { @javax.persistence.EntityResult(entityClass=model.VenueRecord.class) }, columns = { @javax.persistence.ColumnResult(name="distance") })

To this:

@SqlResultSetMapping(name = "findVenuesByDistanceMapping", entities = { @javax.persistence.EntityResult(model.VenueRecord.class) }, columns = { @javax.persistence.ColumnResult("distance")})

You'll notice that it has removed the annotation attribute identifiers. Then when I try to compile the class I get an exception. It seems there is no way to get around this unless I move away from Spring Roo completely. This would be disappointing as I've been using it for months and only recently found an issue I couldn't seem to work around.

Does anyone have any suggestions as to how I can work around this issue? Perhaps even modify the spring roo code to recognise the correct format of annotation?

Jens Schauder
  • 77,657
  • 34
  • 181
  • 348

1 Answers1

0

Just push-in the Roo generated code into your java class. You can archive it in two ways:

  1. Using "AspectJ refactoring/Push in..." context menu option of STS (selecting the the method/declaration on .aj file)
  2. Move the code to de .java file (and remove the class-name prefix).

After that, Roo will detected the method/declaration inside de .java and will not generate it again.

Any way, if you found a problem on Roo generated code, you could report it on Roo Jira so can be fixed on next releases.

Good luck!

jmvivo
  • 2,653
  • 1
  • 16
  • 20
  • Annotations aren't part of the ITD's so cannot be pushed in. Annotations are in the main class, in this respect its an active record class as part of spring roo. – niceguydavie Nov 17 '14 at 13:38
  • Sorry.. Now I can see it. I misunderstood the question. This bug is already reported here (https://jira.spring.io/browse/ROO-3556). – jmvivo Nov 17 '14 at 15:07
  • Yeah I couldn't find anything on the jira so I raised it myself. Thanks for taking a look though. I appreciate it – niceguydavie Nov 25 '14 at 22:26