Session session;
session = CloudSessionFactory.getInstance().openSession();
try {
Transaction txn = session.beginTransaction();
SMeta meta = new SMeta();
meta.setTarget("SObject");
meta.setTargetId(1);
meta.setName("param1");
meta.setValue("value1");
session.save(meta);
logger.info("Meta 1: " + meta.getId());
meta = new SMeta();
meta.setTarget("SObject");
meta.setTargetId(1);
meta.setName("param2");
meta.setValue("value2");
session.save(meta);
logger.info("Meta 2: " + meta.getId());
txn.commit();
} finally {
session.close();
}
session = CloudSessionFactory.getInstance().openSession();
try {
Transaction txn = session.beginTransaction();
Query query = session.createQuery("from SMeta where target=? and targetId=?");
QueryHelper.bindParameters(query, new Object[] {
"SObject", new Long(1)
});
List<SMeta> l = QueryHelper.executeQuery(query);
txn.commit();
for(SMeta meta: l) {
logger.info("" + meta.getName() + "=" + meta.getValue());
}
} finally {
session.close();
}