denismp (21) [Avatar] Offline

It is my understanding that you really don't need the repository layer in implementing an entity. I have already created many entities in my project. Is there an easy way to reset the entities back to activeRecord?

When I tried rerunning the "entity jpa ..." it recreated and empty class and I lost all of my previously defined fields. Is there a better way to do this?
MikB (202) [Avatar] Offline
Re: How do you reset an entity to an activeRecord?
If all you have is simple domain logic, yes, you can get by with active record. It's easier done with the AspectJ itd-techniques too.

What you normally need to do in a situation like yours is to refactor, one step at a time. With version control!

Though I think the fastest way, depending a little though on what you have done so far, is is to just replay an edited version of "log.roo" and make a new project where you use Active Record instead. Then use difference comparisons with a tool like "Compare with each other" in STS, DiffMerge or similar on the old and new project files, to remake more or less the same project, now with the AR pattern.

Again, test first methodology makes transfers like this much easier, faster and safer. As do building modular from the get go.

Unfortunately I think Roo fools many people into thinking they can do things they can't do without deep knowledge of the tools, patterns and frameworks used in a typical Roo-style Spring application. Making design decisions test first will give that knowledge.

Happy hacking around with Roo is also a good learning tool. Especially so with "Spring Roo in Action" in hand as it gives a lot of insights.
MikB (202) [Avatar] Offline
Re: How do you reset an entity to an activeRecord?
On interesting "hack" would be to replace the annotation @RooJpaEntity with @RooJpaActiveRecord and see what happens with your application.

I still do stuff like that with Spring applications — saving to version control first and perhaps making a new branch —, but most often I find it more interesting to have my own tests in place first as that gives more reliable info if the result actually is different or not.
ken.rimple (246) [Avatar] Offline
Re: How do you reset an entity to an activeRecord?
MikB has it nailed. @RooJpaActiveRecord uses the ITD mix-ins at the entity level, and @RooJpaEntity just provides basic JPA @Entity annotations, Generated primary key and versioning support, and is meant to be used with repository jpa commands or direct JPA coding.