How to enforce unique field value in java Google App Engine

Posted by supercobra on Stack Overflow See other posts from Stack Overflow or by supercobra
Published on 2009-10-13T21:41:04Z Indexed on 2010/04/24 16:53 UTC
Read the original article Hit count: 140

Filed under:
|

Hello there,

I am try to find out how to enforce uniqueness in fields other than the unique id.

Example:

@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class User implements IsSerializable {
    @PrimaryKey
    @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
    private Long id;

    @Persistent
    private String name; 

    @Persistent
    private String email; // <= I want this to be unique as well
}

In the example above, how can I enforce uniqueness of the email value across the database?

Daniel

© Stack Overflow or respective owner

Related posts about java

Related posts about google-app-engine