Hi,
i'm using greenDao for the first time. I want to save some data and experienced problems with relations. Here is my szenario:
In my app I want to save some favorites I've chosen before. A favorite is an entity with some StringProperties. Besides that I have other entities. I called them "prices" and "services". A services and a prices -entity has some StringProperties on their own.
Because a price and a service belongs to a favorite I want to set them in relation to each other. If the entities prices and services are some kind of properties of favorite, I could persist them via the favorite object like this:
...
Favorite fav = new Favorite();
fav.setSomeStringProperty("...");
fav.setPrice(prices);
fav.setService(services);
Can you tell me if this is possible?
What I already done so far is that favorite has the fields price and service but all i can do is read and not write or set the data.
I think i'm missing something or didn't totally get how to do it. Here is some code from my DaoGenerator:
Entity favourite = schema.addEntity("Favourite");
favourite.addIdProperty();
favourite.addStringProperty("addressName");
favourite.addStringProperty("addressStreet");
Entity prices = schema.addEntity("Prices");
prices.setTableName("PRICES");
prices.addIdProperty();
prices.addStringProperty("pricesResultValue");
prices.addStringProperty("pricesResultKey");
favId = prices.addLongProperty("favId").notNull().getProperty();
prices.addToOne(favourite, favId);
ToMany pricesToFavs = favourite.addToMany(prices, favId);
pricesToFavs.setName("prices");
Entity services = schema.addEntity("Services");
services.setTableName("SERVICES");
services.addIdProperty();
services.addStringProperty("servicesResultIcon");
services.addStringProperty("servicesResultValue");
favId = services.addLongProperty("favId").notNull().getProperty();
services.addToOne(favourite, favId);
ToMany servicesToFavs = favourite.addToMany(services, favId);
servicesToFavs.setName("services");
Many thanks in advance!!
Emanuel