Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/database/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 解析服务器数据库理解_Java_Database_Codenameone_Parse Server_Parse4cn1 - Fatal编程技术网

Java 解析服务器数据库理解

Java 解析服务器数据库理解,java,database,codenameone,parse-server,parse4cn1,Java,Database,Codenameone,Parse Server,Parse4cn1,我没有使用ParseServer的经验,对于一些事情我有一个令人沮丧的问题。首先是更新对象的方法。好的,我们开始,这是创建对象的过程: 创建对象: ParseObject gameScore = ParseObject.create("GameScore"); gameScore.put("score", 1337); gameScore.put("playerName", "Sean Plott"); gameScore.put("cheatMode", false); gameScore.s

我没有使用ParseServer的经验,对于一些事情我有一个令人沮丧的问题。首先是更新对象的方法。好的,我们开始,这是创建对象的过程:

创建对象:

ParseObject gameScore = ParseObject.create("GameScore");
gameScore.put("score", 1337);
gameScore.put("playerName", "Sean Plott");
gameScore.put("cheatMode", false);
gameScore.save();
// Assuming ParseObject 'gameScore' with key 'score'  already exists.

    gameScore.put("score", 73453);
    gameScore.save();
保存后,我可以通过以下方式获取Id:

String objectId = gameScore.getObjectId();
问题是,如果我以后想访问对象ID,该将其存储在何处?因为我不能使用局部变量来存储对象ID,否则就没有意义了,因为存储是由数据库决定的,而且变量值在重新启动后也会重置

另一个问题:

更新对象:

ParseObject gameScore = ParseObject.create("GameScore");
gameScore.put("score", 1337);
gameScore.put("playerName", "Sean Plott");
gameScore.put("cheatMode", false);
gameScore.save();
// Assuming ParseObject 'gameScore' with key 'score'  already exists.

    gameScore.put("score", 73453);
    gameScore.save();
看起来我只能用另一个对象更新一个对象,但是每次我的应用程序重新启动时,我身边的本地对象都会被重置,这样我的应用程序就无法再次检索到它,以防需要更新它或通过Id获取它

我的意思是,将ID放入本地对象/变量中有什么意义,这些对象/变量将在应用程序重新启动时重置?我的意思是,如果我可以用一个存储的Id而不是另一个对象/变量来更新一个对象,这对我来说是有意义的


如果有人能帮助我理解和澄清这些问题,我将不胜感激。

您需要根据需要使用查询来获取对象,例如,这是我为查询parse数据库而编写的旧代码:

ParseQuery<ParseAttendance> pq = ParseQuery.getQuery(ParseAttendance.class);
pq.setLimit(1000);
pq.setSkip((page - 1) * pq.getLimit());
pq.whereEqualTo("studentId", studentId);
pq.orderByDescending("year");
pq.addDescendingOrder("month");
pq.addDescendingOrder("day");
List<ParseAttendance> lst = pq.find();
ParseQuery pq=ParseQuery.getQuery(parseAttention.class);
pq.设定限值(1000);
pq.setSkip((第1页)*pq.getLimit());
pq.whereEqualTo(“学生ID”,学生ID);
pq.orderByDescending(“年”);
pq.增加下降顺序(“月”);
pq.增加下降顺序(“日”);
List lst=pq.find();
您不保存基于所查找内容查询的对象实例。在本例中,它返回考勤对象的
java.util.List