本文整理了Java中com.googlecode.objectify.Objectify.load()
方法的一些代码示例,展示了Objectify.load()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Objectify.load()
方法的具体详情如下:
包路径:com.googlecode.objectify.Objectify
类名称:Objectify
方法名:load
[英]Start a load command chain. This is where you begin for any request that fetches data from the datastore: gets and queries.
A quick example: Map, Thing> things = ofy().load().type(Thing.class).parent(par).ids(123L, 456L);
All command objects are immutable; this method returns a new object rather than modifying the current command object.
[中]启动加载命令链。这就是从数据存储中获取数据的任何请求的起点:获取和查询。
举个简单的例子:Map,Thing>things=ofy()。加载()。键入(Thing.class)。家长(par)。ids(123L,456L);
所有命令对象都是不可变的;此方法返回一个新对象,而不是修改当前命令对象。
代码示例来源:origin: objectify/objectify
@Override
public T get() {
return ofy().load().now(key());
}
代码示例来源:origin: TEAMMATES/teammates
@Override
protected boolean isMigrationNeeded(Key<FeedbackResponseComment> entity) {
FeedbackResponseComment comment = ofy().load().key(entity).now();
try {
Field commentGiverType = comment.getClass().getDeclaredField("commentGiverType");
commentGiverType.setAccessible(true);
return commentGiverType.get(comment) == null;
} catch (ReflectiveOperationException e) {
return true;
}
}
代码示例来源:origin: TEAMMATES/teammates
@Override
protected Query<FeedbackResponseComment> getFilterQuery() {
return ofy().load().type(FeedbackResponseComment.class);
}
代码示例来源:origin: TEAMMATES/teammates
@Override
protected Query<CourseStudent> getFilterQuery() {
return ofy().load().type(CourseStudent.class);
}
代码示例来源:origin: TEAMMATES/teammates
@Override
protected Query<Account> getFilterQuery() {
return ofy().load().type(Account.class);
}
代码示例来源:origin: TEAMMATES/teammates
@Override
protected Query<Course> getFilterQuery() {
return ofy().load().type(Course.class);
}
代码示例来源:origin: TEAMMATES/teammates
@Override
protected Query<Instructor> getFilterQuery() {
return ofy().load().type(Instructor.class);
}
代码示例来源:origin: TEAMMATES/teammates
@Override
protected Query<Account> getFilterQuery() {
return ofy().load().type(Account.class).filterKey(Key.create(Account.class, fromAccountGoogleId));
}
代码示例来源:origin: TEAMMATES/teammates
@Override
protected boolean isMigrationNeeded(Key<Instructor> key) throws Exception {
Instructor instructor = ofy().load().key(key).now();
if (SanitizationHelper.isSanitizedHtml(instructor.getRole())) {
System.err.println(String.format("Instructor %s has unsanitized role %s, this should not happen",
instructor.getUniqueId(), instructor.getRole()));
}
return SanitizationHelper.isSanitizedHtml(instructor.getDisplayedName());
}
代码示例来源:origin: TEAMMATES/teammates
@Override
protected boolean isMigrationNeeded(Key<Account> key) throws Exception {
Account account = ofy().load().key(key).now();
if (!isMigrationOfGoogleIdNeeded(account)) {
return false;
}
String newGoogleId = generateNewGoogleId(account);
println(String.format("Going to migrate account with googleId %s to new googleId %s",
account.getGoogleId(), newGoogleId));
return true;
}
代码示例来源:origin: TEAMMATES/teammates
@Override
protected boolean isMigrationNeeded(Key<Course> key) throws Exception {
Course course = ofy().load().key(key).now();
return SanitizationHelper.isSanitizedHtml(course.getName());
}
代码示例来源:origin: TEAMMATES/teammates
@Override
public String load(String courseId) {
List<Instructor> instructors =
ofy().load().type(Instructor.class).filter("courseId =", courseId).list();
for (Instructor instructor : instructors) {
if (StringHelper.isEmpty(instructor.getGoogleId())) {
continue;
}
Account account = ofy().load().key(Key.create(Account.class, instructor.getGoogleId())).now();
if (account != null && !StringHelper.isEmpty(account.getInstitute())) {
return account.getInstitute();
}
}
return UNKNOWN_INSTITUTE;
}
});
代码示例来源:origin: TEAMMATES/teammates
@Override
protected boolean isMigrationNeeded(Key<CourseStudent> key) throws Exception {
CourseStudent student = ofy().load().key(key).now();
if (SanitizationHelper.isSanitizedHtml(student.getCourseId())) {
System.err.println(String.format("Student %s has unsanitized courseId %s, this should not happen",
student.getUniqueId(), student.getCourseId()));
}
if (SanitizationHelper.isSanitizedHtml(student.getEmail())) {
System.err.println(String.format("Student %s has unsanitized email %s, this should not happen",
student.getUniqueId(), student.getEmail()));
}
if (SanitizationHelper.isSanitizedHtml(student.getGoogleId())) {
System.err.println(String.format("Student %s has unsanitized googleId %s, this should not happen",
student.getUniqueId(), student.getGoogleId()));
}
if (SanitizationHelper.isSanitizedHtml(student.getSectionName())) {
System.err.println(String.format("Student %s has unsanitized sectionName %s, this should not happen",
student.getUniqueId(), student.getSectionName()));
}
if (SanitizationHelper.isSanitizedHtml(student.getTeamName())) {
System.err.println(String.format("Student %s has unsanitized teamName %s, this should not happen",
student.getUniqueId(), student.getTeamName()));
}
return SanitizationHelper.isSanitizedHtml(student.getComments())
|| SanitizationHelper.isSanitizedHtml(student.getLastName())
|| SanitizationHelper.isSanitizedHtml(student.getName());
}
代码示例来源:origin: TEAMMATES/teammates
@Override
protected void migrateEntity(Key<FeedbackResponseComment> entity) {
FeedbackResponseComment comment = ofy().load().key(entity).now();
comment.setCommentGiverType(FeedbackParticipantType.INSTRUCTORS);
comment.setIsCommentFromFeedbackParticipant(false);
ofy().save().entity(comment).now();
}
}
代码示例来源:origin: TEAMMATES/teammates
@Override
protected void migrateEntity(Key<Course> key) throws Exception {
Course course = ofy().load().key(key).now();
course.setName(SanitizationHelper.desanitizeIfHtmlSanitized(course.getName()));
ofy().save().entity(course).now();
}
}
代码示例来源:origin: TEAMMATES/teammates
@Override
protected void migrateEntity(Key<Instructor> key) throws Exception {
Instructor instructor = ofy().load().key(key).now();
instructor.setDisplayedName(SanitizationHelper.desanitizeIfHtmlSanitized(instructor.getDisplayedName()));
ofy().save().entity(instructor).now();
}
}
代码示例来源:origin: TEAMMATES/teammates
@Override
protected void migrateEntity(Key<Account> oldAccountKey) throws Exception {
Account oldAccount = ofy().load().key(oldAccountKey).now();
String oldGoogleId = oldAccount.getGoogleId();
String newGoogleId = generateNewGoogleId(oldAccount);
StudentProfile oldStudentProfile = ofy().load().key(oldStudentProfileKey).now();
List<CourseStudent> oldStudents = ofy().load().type(CourseStudent.class)
.filter("googleId =", oldGoogleId).list();
List<Instructor> oldInstructors = ofy().load().type(Instructor.class)
.filter("googleId =", oldGoogleId).list();
if (ofy().load().type(Account.class).id(newGoogleId).now() == null) {
ofy().save().entity(oldAccount).now();
} else {
代码示例来源:origin: TEAMMATES/teammates
ofy().load().type(CourseStudent.class)
.filter("createdAt >", queryEntitiesFrom)
.filter("createdAt <=", queryEntitiesTo);
Query<Account> accountQuery =
ofy().load().type(Account.class)
.filter("createdAt >", queryEntitiesFrom)
.filter("createdAt <=", queryEntitiesTo);
代码示例来源:origin: TEAMMATES/teammates
@Override
protected void migrateEntity(Key<CourseStudent> key) throws Exception {
CourseStudent student = ofy().load().key(key).now();
student.setComments(SanitizationHelper.desanitizeIfHtmlSanitized(student.getComments()));
student.setName(SanitizationHelper.desanitizeIfHtmlSanitized(student.getName()));
student.setLastName(SanitizationHelper.desanitizeIfHtmlSanitized(student.getLastName()));
ofy().save().entity(student).now();
}
}
代码示例来源:origin: com.threewks.thundr/thundr-gae
protected List<E> loadInternal(Iterable<Key<E>> keys) {
if (Expressive.isEmpty(keys)) {
return Collections.<E> emptyList();
}
Map<Key<E>, E> results = ofy().load().keys(keys);
return Expressive.Transformers.transformAllUsing(Expressive.Transformers.usingLookup(results)).from(keys);
}
内容来源于网络,如有侵权,请联系作者删除!