Note that there are some explanatory texts on larger screens.

plurals
  1. POCaching nested objects in Robospice with ORMLite
    primarykey
    data
    text
    <p>Is it possible to cache nested (2-3 level of nesting) objects (foreign fields) via Robospice/ORMlite? <a href="https://groups.google.com/forum/#!msg/robospice/VGLB3-vM3Ug/-piOac212HYJ" rel="nofollow">https://groups.google.com/forum/#!msg/robospice/VGLB3-vM3Ug/-piOac212HYJ</a> - there you can read that is possible, but unfortunatelly I can't achieve it.</p> <p>Here is my source code:</p> <pre><code>@DatabaseTable(tableName = "city") @JsonIgnoreProperties(ignoreUnknown = true) public class City { @DatabaseField(id = true) @JsonProperty("id") private long id; @DatabaseField @JsonProperty("name") private String name; @ForeignCollectionField(eager = true, maxEagerLevel = 3) @JsonProperty("clubs") private Collection&lt;Club&gt; clubs; ... @DatabaseTable(tableName = "club") @JsonIgnoreProperties(ignoreUnknown = true) public class Club { @DatabaseField(id = true) @JsonProperty("user_id") private long id; @DatabaseField @JsonProperty("name") private String name; @DatabaseField(foreign = true, foreignAutoRefresh = true, columnName = "city_id", maxForeignAutoRefreshLevel = 2) private City city; @DatabaseField(foreign = true) @JsonProperty("address") private VenueAddress address; ... @DatabaseTable(tableName = "address") @JsonIgnoreProperties(ignoreUnknown = true) public class VenueAddress { @DatabaseField(id = true) @JsonProperty("uid") private long id; @DatabaseField @JsonProperty("street") private String street; @DatabaseField @JsonProperty("street_number") private String streetNumber; @DatabaseField @JsonProperty("country") private String country; @DatabaseField(foreign = true, foreignAutoRefresh = true, columnName = "club_id", maxForeignAutoRefreshLevel = 2) private Club club; ... </code></pre> <p>And sample SpiceService:</p> <pre><code>public class SampleSpiceService extends SpringAndroidSpiceService { private static final int WEBSERVICES_TIMEOUT = 10000; @Override public CacheManager createCacheManager(Application application) { CacheManager cacheManager = new CacheManager(); List&lt;Class&lt;?&gt;&gt; classCollection = new ArrayList&lt;Class&lt;?&gt;&gt;(); // add persisted classes to class collection classCollection.add(VenueAddress.class); classCollection.add(City.class); classCollection.add(Club.class); // init RoboSpiceDatabaseHelper databaseHelper = new RoboSpiceDatabaseHelper(application, "sample_database.db", 5); InDatabaseObjectPersisterFactory inDatabaseObjectPersisterFactory = new InDatabaseObjectPersisterFactory( application, databaseHelper, classCollection); cacheManager.addPersister(inDatabaseObjectPersisterFactory); return cacheManager; } @Override public RestTemplate createRestTemplate() { RestTemplate restTemplate = new RestTemplate(); // set timeout for requests HttpComponentsClientHttpRequestFactory httpRequestFactory = new HttpComponentsClientHttpRequestFactory(); httpRequestFactory.setReadTimeout(WEBSERVICES_TIMEOUT); httpRequestFactory.setConnectTimeout(WEBSERVICES_TIMEOUT); restTemplate.setRequestFactory(httpRequestFactory); MappingJacksonHttpMessageConverter messageConverter = new MappingJacksonHttpMessageConverter(); restTemplate.getMessageConverters().add(messageConverter); restTemplate.getMessageConverters().add(new StringHttpMessageConverter()); return restTemplate; } } </code></pre> <p>And when I fetch City object from cache it has clubs collection, but VenueAddress in each Club has null fields (except id). Do you have any advices? </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload