Hi there,
I hav two DataSources person.xml and address.xml.
I want to make a RPC call and retrieve a person and its address (like in hibernate).
Everything works fine but now I´m trying to get the person and its address on the same request, something like:
Thanks in advance!
I hav two DataSources person.xml and address.xml.
I want to make a RPC call and retrieve a person and its address (like in hibernate).
Code:
<Person.xml> ... <fields> <field primaryKey="true" name="id" length="10" type="text"></field> <field primaryKey="true" name="address" foreignKey="Address.id" length="3" type="text"></field> ... </fields> ... <Address.xml> <fields> <field primaryKey="true" name="id" length="10" type="number"></field> <field name="street" length="10" type="text"></field> <field name="area_code" length="10" type="text"></field> <field name="city" length="10" type="text"></field> ...
Code:
DataSource personDS = DataSource.get("PersonDS"); Criteria personCriteria = new Criteria(); personCriteria.addCriteria("id", 15); personDS.fetchData(personCriteria, new DSCallback() { @Override public void execute(DSResponse aResponse, Object aRawData, DSRequest aRequest) { Record[] persons = aResponse.getData(); if(persons != null && persons.length == 1){ records[0].getAttributeAsString("name"); // I want here to get the Address DATA aswell! Is is possible? records[0].getAttributeAsString("address.street"); records[0].getAttributeAsString("address.area_code"); records[0].getAttributeAsString("address.city"); } } });
Comment