use of io.jans.orm.sql.model.SimpleCacheEntry in project jans by JanssenProject.
the class SqlUpateCacheEntrySample method main.
public static void main(String[] args) {
// Prepare sample connection details
SqlEntryManagerSample sqlEntryManagerSample = new SqlEntryManagerSample();
// Create SQL entry manager
SqlEntryManager sqlEntryManager = sqlEntryManagerSample.createSqlEntryManager();
String key = UUID.randomUUID().toString();
final String cacheDn = String.format("uuid=%s,%s", key, "ou=cache,o=gluu");
int expirationInSeconds = 60;
Calendar expirationDate = Calendar.getInstance();
expirationDate.setTime(new Date());
expirationDate.add(Calendar.SECOND, expirationInSeconds);
SimpleCacheEntry entity = new SimpleCacheEntry();
entity.setTtl(expirationInSeconds);
entity.setData("sample_data");
entity.setId(key);
entity.setDn(cacheDn);
entity.setCreationDate(new Date());
entity.setExpirationDate(expirationDate.getTime());
entity.setDeletable(true);
sqlEntryManager.persist(entity);
// Try to update
sqlEntryManager.merge(entity);
// Try to update with removed value
entity.setData(null);
sqlEntryManager.merge(entity);
}
Aggregations