앱 엔진에서 키 생성을위한 문서를 읽고 있습니다. 간단한 String 키를 사용하여 어떤 효과가 실제 키보다 큰지 확실하지 않습니다. 내가 제대로 문서를 이해한다면, 나는 아직도이 사용라는 이름의 키와 엔티티 그룹을 생성 할 수있는 권리?인코딩되지 않은 키와 실제 키를 사용하면 이점이 있습니까?
해야 지금class User {
/** Key type = unencoded string. */
@PrimaryKey
private String name;
}
예를 들어, 내 사용자가 가입 할 때, 그들은 고유 한 사용자 이름을 제공해야합니다
// Find an instance of this entity:
User user = pm.findObjectById(User.class, "myusername");
// Create a new obj and put it in same entity group:
Key key = new KeyFactory.Builder(
User.class.getSimpleName(), "myusername")
.addChild(Goat.class.getSimpleName(), "baa").getKey();
Goat goat = new Goat();
goat.setKey(key);
pm.makePersistent(goat);
Goat 인스턴스는 이제 해당 사용자와 동일한 엔티티 그룹에 있어야합니다. 맞습니까? 사용자의 기본 키를 원시 문자열로 남겨두면 아무런 문제가 없다는 것을 의미합니까?
Key를 사용하면 성능상의 이점이 있습니까? 에 나는 업데이트해야합니다 : 당신은 당신 같은 문자열 키를 지정하는 경우는 거의 같은 일이
class User {
/** Key type = unencoded string. */
@PrimaryKey
private Key key;
}
// Generate like:
Key key = KeyFactory.createKey(
User.class.getSimpleName(),
"myusername");
user.setKey(key);
, 나는 여전히, 어쨌든 고유 한 사용자 이름을 사용하여 키를 생성
감사
지금 보니, 감사합니다. – user246114