Late answer, but... First it looks like the wordId would be a more natural PK for the WordEntity. The LexiconEntity should also define a PrimaryKey. The WordEntity should define the SecondaryKey which refers to the LexiconEntity or "Specifies the entity to which this entity is related".
public class WordEntity {
@PrimaryKey
private int wordId;
private String content;
@SecondaryKey(relate = Relationship.ONE_TO_ONE, relatedEntity = LexiconEntity.class)
private int lexId;
}
public class LexiconEntity {
@PrimaryKey
private int lexId;
private int numDocs;
}
Therefore data would be:
LexiconEntity:
lexId
-----
100
101
102
WordEntity:
wordId lexId
------ -----
1 100
2 101
3 102
Since the relationship is one_to_one, the secondary key is unique to the object defining it. So in this case, lexId is unique in the WordEntity, so you cannot have:
WordEntity:
wordId lexId
------ -----
1 100
2 101
3 100 -- Exception on insert since it is a dup
See http://docs.oracle.com/cd/E17277_02/html/GettingStartedGuide/dplindexcreate.html#dplsecondaryidxdecl
http://docs.oracle.com/cd/E17277_02/html/java/com/sleepycat/persist/model/SecondaryKey.html#relatedEntity()