本文整理汇总了Java中com.erudika.para.core.ParaObject.setAppid方法的典型用法代码示例。如果您正苦于以下问题:Java ParaObject.setAppid方法的具体用法?Java ParaObject.setAppid怎么用?Java ParaObject.setAppid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.erudika.para.core.ParaObject
的用法示例。
在下文中一共展示了ParaObject.setAppid方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createAll
import com.erudika.para.core.ParaObject; //导入方法依赖的package包/类
@Override
public <P extends ParaObject> void createAll(String appid, List<P> objects) {
if (objects == null || objects.isEmpty() || StringUtils.isBlank(appid)) {
return;
}
List<Document> documents = new ArrayList<Document>();
for (ParaObject so : objects) {
if (so != null) {
if (StringUtils.isBlank(so.getId())) {
so.setId(MongoDBUtils.generateNewId());
logger.debug("Generated id: " + so.getId());
}
if (so.getTimestamp() == null) {
so.setTimestamp(Utils.timestamp());
}
so.setAppid(appid);
documents.add(toRow(so, null, false, true));
}
}
if (!documents.isEmpty()) {
getTable(appid).insertMany(documents);
}
logger.debug("DAO.createAll() {}", objects.size());
}
示例2: createAll
import com.erudika.para.core.ParaObject; //导入方法依赖的package包/类
@Override
public <P extends ParaObject> void createAll(String appid, List<P> objects) {
if (objects == null || objects.isEmpty() || StringUtils.isBlank(appid)) {
return;
}
ArrayList<String> values = new ArrayList<String>(objects.size());
StringBuilder batch = new StringBuilder("BEGIN BATCH ");
for (ParaObject so : objects) {
if (so != null) {
if (StringUtils.isBlank(so.getId())) {
so.setId(Utils.getNewId());
logger.debug("Generated id: " + so.getId());
}
if (so.getTimestamp() == null) {
so.setTimestamp(Utils.timestamp());
}
so.setAppid(appid);
batch.append("INSERT INTO ").append(CassandraUtils.getTableNameForAppid(appid)).
append(" (id, json) VALUES (?, ?);");
values.add(so.getId());
values.add(toRow(so, null));
}
}
if (!values.isEmpty()) {
batch.append("APPLY BATCH");
PreparedStatement ps = getClient().prepare(batch.toString());
getClient().execute(ps.bind(values.toArray()));
}
logger.debug("DAO.createAll() {}", objects.size());
}
示例3: deleteAll
import com.erudika.para.core.ParaObject; //导入方法依赖的package包/类
@Override
public <P extends ParaObject> void deleteAll(String appid, List<P> objects) {
if (objects == null || objects.isEmpty() || StringUtils.isBlank(appid)) {
return;
}
try {
ArrayList<String> values = new ArrayList<String>(objects.size());
StringBuilder batch = new StringBuilder("BEGIN BATCH ");
for (ParaObject so : objects) {
if (so != null) {
so.setAppid(appid);
batch.append("DELETE FROM ").append(CassandraUtils.getTableNameForAppid(appid)).
append(" WHERE id = ?;");
values.add(so.getId());
}
}
if (!values.isEmpty()) {
batch.append("APPLY BATCH");
PreparedStatement ps = getClient().prepare(batch.toString());
getClient().execute(ps.bind(values.toArray()));
}
} catch (Exception e) {
logger.error(null, e);
}
logger.debug("DAO.deleteAll() {}", objects.size());
}