tags:

views:

31

answers:

1

I'm working with Spring Roo and I need to overwrite Roo's Remove() method in the Roo_Entity.aj file. I'm getting a lot of Foreign Key constraint errors when I try to delete my entity, although I think my JPA annotations are correct.

What I'm trying to do is overwrite the Remove() method in the Roo_Entity.aj file, to manually check for foreign keys and remove the offending records before my transaction commits.

I've created my own Remove() method in my .java file, however Roo is not updating the Roo_Entity.aj file automatically and I've had to manually delete and edit the .aj file. Should Roo recognise that I've manually created a Remove() method in my .java file and manage the Roo_entity.aj file accordingly?

Thanks in advance!

A: 

Yes, the Roo Shell should see that you have implemented the remove() in your entity class and remove it from Roo_Entity.aj automatically. Some things to check if it's not working for you:

  • Is the Roo Shell running? It has to in order to manage the aspects for you.
  • It's remove(), not Remove(), right?
  • Is the signature identical? public void remove()?
  • Have you saved the changes to disk? The shell monitors the filesystem, so unless you save it can't see your changes.
  • If you are using the SpringSource Tool Suite: Have you tried the "AspectJ Refactoring"->"Push In..." refactoring in the IDE?

In general, you should never have to edit the Roo_*.aj files manually.

wallenborn
Thanks for your answer. I originally had Roo running while I was coding, but I lost all of my aspect files. I believe it deletes all of the aspects if you have a compilation error. I didn't turn it back on. I followed your list, and it managed the remove method in the entity file. Thanks!
Ryn