Aug 2nd, 2010, 02:05 PM
Newbie Question - Primary Key?
Hi folks. I'm gearing up to start a Roo project once 1.1.0M3 comes out, so for now I'm just trying to understand the basics so I can hit the ground running.
My question: Is there any way to specify a primary key for a DB table that isn't an auto-generated ID? My project will have a "User" object, so I assumed it'd be best to have the users login/username be the primary key (as I obviously won't allow more than one User to have the same value). I can't seem to find any documentation or posts on setting a field as the primary key.
Aug 3rd, 2010, 05:41 PM
I think these are two different issues. You can actually look into JPA documentation of how you can put a Column uniqueness constraint on the username (it will make sure you don't have more than one username in that column)
You can also specify your IDs generation with annotation as well via JPA and let it do the magic.
One problem with unique column is that it would throw a default exception. I think this feature could be a plugin where you put in a column as unique and it also puts in validation for your spring-mvc in ROO.
Edit: I actually planned on working on this any way, here you go. http://hatimonline.com/2010/08/04/sp...ty-tutorial-0/
Last edited by hatim; Aug 3rd, 2010 at 07:53 PM.
Reason: putting link to blog post