Menu

Primary Key/Unique Field

Help Java
2009-09-24
2013-05-29
  • Stephan Knitelius

    How can I define a Field to be Unique? Is it possible to define a Field as being Unique for Primary Key purposes.

     
  • Olivier

    Olivier - 2009-09-25

    Hi,

    you can do like this:

    ODB odb = open("baseName");
    ClassRepresentation clazz = odb.getClassRepresentation(IndexedObject.class);
    String indexFields = { "name", "duration" };
    clazz.addUniqueIndexOn("index1", indexFields, true);

    Olivier

     
  • David Parks

    David Parks - 2010-12-29

    I have the same question here. I'm using NeoDatis under DataNucleus and not finding a way to ensure two User objects with the same  field aren't added to the DB

     

Log in to post a comment.