Announcement Announcement Module
No announcement yet.
Newbie Question - Primary Key? Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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.

  • #2
    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.
    Last edited by hatim; Aug 3rd, 2010, 07:53 PM. Reason: putting link to blog post