greenrobot/greenDAO — pull request #9 by manuelciosici (2012-01-14 17:12:26+00:00)
Title: Added possibility to name the ToOne relationships

I added the possibility to create ToOne relationships with the following API:

Property capitalLocationId = entCounty.addLongProperty("capitalLocationId").getProperty();
entCounty.addToOne(entLocationInImage, capitalLocationId, "capitalLocation");

The last parameter is the name for the relationship. Normally when creating two properties in the traditional way addToOne(targetEntity, localProperty) the target entity class is used. This makes it impossible to add multiple toOne relationships to the baseEntity to the targetEntity. In my case the code looks like this:

Property capitalLocationId = entCounty.addLongProperty("capitalLocationId").getProperty();
entCounty.addToOne(entLocationInImage, capitalLocationId, "capitalLocation");
Property countyLocationId = entCounty.addLongProperty("countyLocationId").getProperty();
entCounty.addToOne(entLocationInImage, countyLocationId, "countyLocation");