I am using it in an ORMLite project and I have a small problem with ORMLite. It turns out that I have the following list of entities:
- One Area has Many Monitoring Points
- A Municipality has Many Areas
- A Province has Many Municipalities
These relationships I am treating them in this way: Ex:
public class Area implements Serializable {
@DatabaseField(generatedId = true, columnName = ID, unique = true)
private int id;
(....)
@ForeignCollectionField
private ForeignCollection<PuntodeMonitoreo> puntos;
}
public class PuntodeMonitoreo implements Serializable {
(...)
@DatabaseField(foreign = true, foreignAutoRefresh = true, canBeNull = false, columnName = AREA)
private Area area;
}
and so on with the other relationships. My problem occurs when I get the list of the Monitoring Points and try to show each one in a CardView
* When I get an object from PuntodeMonitoring (obj) and I say:
String prov = obj.getArea().getTown().getProvince().getName()
This returns " unknow " which is the text with which I initialized the variable "name" in the empty constructor of the Provincia class.
The "translation" of this line of code [ obj.getArea().getTown().getProvince().getName() ]
means:
PuntodeMonitoreo give me your Area, Area give me your Municipality and Province give me your Name
But he returns me. Use the Debugger and there is a call to the empty Province builder when I ask for the Monitoring Point list with the queryForAll()
* It is curious that the id attribute of the class Provincia in the Debugger has a valid value, when in the empty constructor I initialized this attribute with -1.
I hope you can help me. Thanks