I used the JPA examples from this article to implement the relationship annotations.
Could that be my issue? @JPA annotations mixed with @Roo annotations with @Hibernate annotations?
I used the JPA examples from this article to implement the relationship annotations.
Could that be my issue? @JPA annotations mixed with @Roo annotations with @Hibernate annotations?
The "Roo way" for entity relationships is really the JPA way.
There's no need to worry much about using your own id fields unless you have specific requirements for these.
You manage entity relations by using field set the field reference.
For many to many relationships there is a good example in part 8.3 of the roo documentation. It's a great idea to both read the documentation for Roo as well as the Spring framework.
I can also recommend again the book Spring Roo in Action MEAP.. Those $30 can save save you a lot of time.
Not necessarily so, but it's good idea to proceed in a minimalistic way as things then only may not work in limited ways, which makes it easier to fix problems and add on functionality piece by piece. Also, Roo uses JPA2 and I think that article may be focused on JPA first version. It's still a good overview though.
As I've already pointed out it's only necessary to set names of tables and nullable on the database itself when you actually need it, becauseof requirements.
It's a good practice to do as little as needed first, making sure your minimal set of planned entities work by writing tests that do things with these they way you expect them to work.
Only when those tests run green then add the web tier for your entities. This way you'll be sure the problem is not within your domain objects themselves. Of course it's very possible to have web tier and still make use of those tests. My point is that if you have verified your domain objects by tests including validation constraints, then you'll know that those functions are operative, making it easier to design the view and find out what's not working the way you want. Tests save time in my experience.
While you may not need it for simpler applications a good book on JPA2 is a good idea IMHO. I got both "Pro JPA 2: Mastering the Java Persistence API" on apress and "Java Persistence with Hibernate" from Manning, though the latter is not JPA2.
Last edited by MiB; Mar 25th, 2011 at 07:10 AM.