Overwrite Spring Roo Entity method
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 b开发者_JAVA百科efore 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!
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.
精彩评论