Java 8은 지원이 종료되었으며 2026년 1월 31일에 지원 중단됩니다. 지원 중단 후에는 조직에서 이전에 조직 정책을 사용하여 레거시 런타임의 배포를 다시 사용 설정한 경우에도 Java 8 애플리케이션을 배포할 수 없습니다. 기존 Java 8 애플리케이션은 지원 중단 날짜 이후에도 계속 실행되고 트래픽을 수신합니다. 지원되는 최신 Java 버전으로 마이그레이션하는 것이 좋습니다.
Datastore의 데이터 객체를 항목이라고 하며, 각 항목은 쿼리를 위해 특정한 종류로 분류됩니다. 예를 들어 인사 관리 애플리케이션을 작성하는 경우 각 직원을 Employee 종류의 항목으로 나타낼 수 있습니다. 항목 데이터 값의 형식은 속성이라는 점에 유의하세요.
항목에 대한 자세한 내용은 항목, 속성, 키 개념 문서를 참조하세요.
항목 생성 및 속성 설정
Java에서는 Entity 클래스의 인스턴스를 생성하면서 Entity() 생성자에 항목 종류를 인수로 제공하여 새 항목을 만듭니다. 필요한 경우 항목 속성에 값을 채운 후 DatastoreService.put() 메서드에 인수로 전달하여 Datastore에 저장합니다. 항목의 키 이름을 지정하려면 생성자의 두 번째 인수로 전달하면 됩니다.
다음 예시에서는 Employee 종류의 항목을 만들고, 속성 값을 채우고, Datastore에 저장합니다.
이러한 일괄 작업에서는 모든 항목 또는 키를 항목 그룹으로 묶은 후 요청된 작업을 각 항목 그룹에 대해 병렬로 수행합니다. 이 방식은 서비스 호출에 따르는 오버헤드가 한 번만 발생하므로 개별 항목을 일일이 따로 호출하는 방식보다 속도가 빠릅니다. 일괄 처리에 여러 항목 그룹이 사용되는 경우 서버 측에서 모든 그룹에 대한 작업이 병렬로 수행됩니다.
put() 또는 delete() 일괄 호출은 항목에 따라 성공적으로 작동하거나 그렇지 않을 수 있습니다.
호출이 완전히 성공하거나 완전히 실패하는 것이 중요한 경우에는 모든 항목이 동일한 항목 그룹에 포함된 트랜잭션을 사용하세요.
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["이해하기 어려움","hardToUnderstand","thumb-down"],["잘못된 정보 또는 샘플 코드","incorrectInformationOrSampleCode","thumb-down"],["필요한 정보/샘플이 없음","missingTheInformationSamplesINeed","thumb-down"],["번역 문제","translationIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-09-04(UTC)"],[[["\u003cp\u003eThis API supports first-generation runtimes and can be used when upgrading to corresponding second-generation runtimes, with a migration guide available for App Engine Java 11/17 runtime updates.\u003c/p\u003e\n"],["\u003cp\u003eEntities are data objects in Datastore, categorized under a specific kind for queries, with properties defining their data values.\u003c/p\u003e\n"],["\u003cp\u003eEntities are created in Java using the \u003ccode\u003eEntity\u003c/code\u003e class and saved to Datastore via the \u003ccode\u003eDatastoreService.put()\u003c/code\u003e method, and can be named with a key or given an automatically generated numeric ID.\u003c/p\u003e\n"],["\u003cp\u003eTo update an existing entity, modify its attributes and use \u003ccode\u003eDatastoreService.put()\u003c/code\u003e, overwriting the existing entity, while \u003ccode\u003eDatastoreService.delete()\u003c/code\u003e is used to delete entities based on their keys.\u003c/p\u003e\n"],["\u003cp\u003eBatch operations allow multiple entities to be handled in a single Datastore call, improving efficiency by grouping entities by entity groups and performing operations in parallel.\u003c/p\u003e\n"]]],[],null,["# Creating, Retrieving, Updating, and Deleting Entities\n\n| This API is supported for first-generation runtimes and can be used when [upgrading to corresponding second-generation runtimes](/appengine/docs/standard/\n| java-gen2\n|\n| /services/access). If you are updating to the App Engine Java 11/17 runtime, refer to the [migration guide](/appengine/migration-center/standard/migrate-to-second-gen/java-differences) to learn about your migration options for legacy bundled services.\n\n\u003cbr /\u003e\n\nData objects in Datastore are known as *entities* , each of which is categorized\nunder a particular *kind* for the purpose of queries. For\ninstance, if you are writing a human resources application you might represent\neach employee with an entity of kind `Employee`. Note that the entity data\nvalues are in the form of\n\n[properties](/appengine/docs/legacy/standard/java/datastore/entity-property-reference#properties_and_value_types).\n\n\nFor more information about entities, see the concept document\n[Entities, Properties, and Keys](/appengine/docs/legacy/standard/java/datastore/entities).\n| **Important:** Inefficient data store code can result in unnecessarily high costs! So before you write your code, you should learn about [write costs](/datastore/pricing).\n\nCreating entities and setting properties\n----------------------------------------\n\nIn Java, you create a new entity by constructing an instance of class\n[`Entity`](/appengine/docs/legacy/standard/java/javadoc/com/google/appengine/api/datastore/Entity), supplying the entity's kind as an\nargument to the [`Entity()`](/appengine/docs/legacy/standard/java/javadoc/com/google/appengine/api/datastore/Entity#Entity-java.lang.String-)\nconstructor. After populating the entity's properties if necessary, you save it\nto the datastore by passing it as an argument to the\n[`DatastoreService.put()`](/appengine/docs/legacy/standard/java/javadoc/com/google/appengine/api/datastore/DatastoreService#put-com.google.appengine.api.datastore.Entity-)\nmethod. You can specify the entity's key name by passing it as the second\nargument to the constructor.\n\nThe following example creates an entity of kind `Employee`, populates its property values, and saves it to data store: \n\n Entity employee = new Entity(\"Employee\", \"asalieri\");\n employee.setProperty(\"firstName\", \"Antonio\");\n employee.setProperty(\"lastName\", \"Salieri\");\n employee.setProperty(\"hireDate\", new Date());\n employee.setProperty(\"attendedHrTraining\", true);\n\n DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();\n datastore.put(employee);\n\nNote that if you don't provide a key name, Datastore automatically\ngenerates a numeric ID for the entity's key: \n\n Entity employee = new Entity(\"Employee\");\n // Set the entity properties.\n // ...\n datastore.put(employee);\n\nRetrieving entities\n-------------------\n\nTo retrieve an entity identified by a given key, pass the [`Key`](/appengine/docs/legacy/standard/java/javadoc/com/google/appengine/api/datastore/Key)\nobject to the [`DatastoreService.get()`](/appengine/docs/legacy/standard/java/javadoc/com/google/appengine/api/datastore/DatastoreService#get-com.google.appengine.api.datastore.Key-) method: \n\n // Key employeeKey = ...;\n Entity employee = datastore.get(employeeKey);\n\nUpdating entities\n-----------------\n\nTo update an existing entity, modify the attributes of the Entity object, then pass it to the [`DatastoreService.put()`](/appengine/docs/legacy/standard/java/javadoc/com/google/appengine/api/datastore/DatastoreService#put-com.google.appengine.api.datastore.Entity-) method. The object data overwrites the existing entity. The entire object is sent to Datastore with every call to `put()`. \n\n Entity employee = new Entity(\"Employee\", \"asalieri\");\n employee.setProperty(\"firstName\", \"Antonio\");\n employee.setProperty(\"lastName\", \"Salieri\");\n employee.setProperty(\"hireDate\", new Date());\n employee.setProperty(\"attendedHrTraining\", true);\n\n DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();\n datastore.put(employee);\n\n| **Note:** The Datastore API does not distinguish between creating a new entity and updating an existing one. If the object's key represents an entity that already exists, the `put()` method overwrites the existing entity. You can use a [transaction](/appengine/docs/legacy/standard/java/datastore/transactions) to test whether an entity with a given key exists before creating one.\n\nDeleting entities\n-----------------\n\nGiven an entity's key, you can delete the entity with the [`DatastoreService.delete()`](/appengine/docs/legacy/standard/java/javadoc/com/google/appengine/api/datastore/DatastoreService#e-com.google.appengine.api.datastore.Key...-) method: \n\n // Key employeeKey = ...;\n datastore.delete(employeeKey);\n\nDeleting entities in bulk\n-------------------------\n\nIf you need to delete a large number of entities, we recommend [using\nDataflow to delete entities in bulk](/datastore/docs/bulk-delete).\n\nUsing batch operations\n----------------------\n\nYou can use the batch operations if you want to operate on multiple\nentities in a single Datastore call.\n\nHere is an example of a batch call: \n\n Entity employee1 = new Entity(\"Employee\");\n Entity employee2 = new Entity(\"Employee\");\n Entity employee3 = new Entity(\"Employee\");\n // ...\n\n List\u003cEntity\u003e employees = Arrays.asList(employee1, employee2, employee3);\n datastore.put(employees);\n\nThese batch operations group all the entities or keys by\n[entity group](/appengine/docs/legacy/standard/java/datastore/entities#Transactions_and_entity_groups)\nand then perform the requested operation on each entity group in parallel,\nwhich is faster than making separate calls for each individual entity because\nthey incur the overhead for only one service call. If the batch uses multiple\nentity groups, the work for all groups is done in parallel on the server side.\n\nA batch `put()` or `delete()` call may succeed for some entities but not others.\nIf it is important that the call succeed completely or fail completely, use\na [transaction](/appengine/docs/legacy/standard/java/datastore/transactions) with all affected\nentities in the same entity group.\n| **Note:** Attempting a batch operation inside a transaction with entities or keys belonging to multiple entity groups will result in an `IllegalArgumentException`."]]