// Entity employee = ...;// Entity contactInfo = ...;EmbeddedEntityembeddedContactInfo=newEmbeddedEntity();embeddedContactInfo.setKey(contactInfo.getKey());// Optional, used so we can recover original.embeddedContactInfo.setPropertiesFrom(contactInfo);employee.setProperty("contactInfo",embeddedContactInfo);
[[["わかりやすい","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 is for first-generation runtimes and can be used when upgrading to corresponding second-generation runtimes, with a migration guide provided for those updating to App Engine Java 11/17.\u003c/p\u003e\n"],["\u003cp\u003eFirestore in Datastore mode supports various data types, including integers, floating-point numbers, strings, dates, and binary data, each with specific Java type equivalents and sort orders.\u003c/p\u003e\n"],["\u003cp\u003eProperties in Datastore can be indexed or unindexed, and an entity can have at most 20,000 indexed properties, with multiple-valued properties being useful for queries with equality filters.\u003c/p\u003e\n"],["\u003cp\u003eShort text strings and byte strings (up to 1500 bytes) are indexed, whereas long text and byte strings (up to 1 megabyte) are not, and embedded entity properties are never indexed.\u003c/p\u003e\n"],["\u003cp\u003eBy setting the \u003ccode\u003eDATASTORE_EMPTY_LIST_SUPPORT\u003c/code\u003e property to true, you can enable the storage of empty lists in Datastore, but it's important to understand how this change could affect existing queries.\u003c/p\u003e\n"]]],[],null,["# Entity Property Reference\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\nFirestore in Datastore mode (Datastore) supports a variety of\n[data types for property values](#Properties_and_value_types). These include,\namong others:\n\n- Integers\n- Floating-point numbers\n- Strings\n- Dates\n- Binary data\n\nFor a full list of types, see\n\n\n[Properties and value types](#properties_and_value_types).\n\n\nProperties and value types\n--------------------------\n\nThe data values associated with an entity consist of one or more *properties.* Each property has a name and one or more values. A property can have values of more than one type, and two entities can have values of different types for the same property. Properties can be indexed or unindexed (queries that order or filter on a property *P* will ignore entities where *P* is unindexed). An entity can have at most 20,000 indexed properties.\n| **Note:** Properties with multiple values can be useful, for instance, when performing queries with equality filters: an entity satisfies the query if any of its values for a property matches the value specified in the filter. For more details on multiple-valued properties, including issues you should be aware of, see the [Datastore Queries](/appengine/docs/legacy/standard/java/datastore/queries) page.\n\nThe following value types are supported:\n\n**Important:** We strongly recommend that you avoid storing a `users.User` as a property value, because this includes the email address along with the unique ID. If a user changes their email address and you compare their old, stored\n`user.User` to the new `user.User` value, they won't match. Instead, use the `User` *user ID value* as the user's stable unique identifier.\n\nFor text strings and unencoded binary data (byte strings), Datastore supports two value types:\n\n- Short strings (up to 1500 bytes) are indexed and can be used in query filter conditions and sort orders.\n- Long strings (up to 1 megabyte) are not indexed and cannot be used in query filters and sort orders.\n\nNote: The long byte string type is named [`Blob`](/appengine/docs/legacy/standard/java/javadoc/com/google/appengine/api/datastore/Blob) in the Datastore API. This type is unrelated to blobs as used in the [Blobstore API](/appengine/docs/legacy/standard/java/blobstore).\n\nWhen a query involves a property with values of mixed types, Datastore uses a deterministic ordering based on the internal representations:\n\n1. Null values\n2. Fixed-point numbers\n - Integers\n - Dates and times\n - Ratings\n3. Boolean values\n4. Byte sequences\n - Byte string\n - Unicode string\n - Blobstore keys\n5. Floating-point numbers\n6. Geographical points\n7. Google Accounts users\n8. Datastore keys\n\n\u003cbr /\u003e\n\nBecause long text strings, long byte strings, and embedded entities are not indexed, they have no ordering defined.\n| **Note:** Integers and floating-point numbers are considered separate types in Datastore. If an entity uses a mix of integers and floats for the same property, all integers will be sorted before all floats: for example, \n|\n| `7` \\\u003c `3.2`\n\n### Repeated properties\n\nYou can store multiple values within a single property. \n\n Entity employee = new Entity(\"Employee\");\n ArrayList\u003cString\u003e favoriteFruit = new ArrayList\u003cString\u003e();\n favoriteFruit.add(\"Pear\");\n favoriteFruit.add(\"Apple\");\n employee.setProperty(\"favoriteFruit\", favoriteFruit);\n datastore.put(employee);\n\n // Sometime later\n employee = datastore.get(employee.getKey());\n @SuppressWarnings(\"unchecked\") // Cast can't verify generic type.\n ArrayList\u003cString\u003e retrievedFruits = (ArrayList\u003cString\u003e) employee\n .getProperty(\"favoriteFruit\");\n\n### Embedded entities\n\nYou may sometimes find it convenient to embed one entity as a property of another entity. This can be useful, for instance, for creating a hierarchical structure of property values within an entity. The Java class [`EmbeddedEntity`](/appengine/docs/legacy/standard/java/javadoc/com/google/appengine/api/datastore/EmbeddedEntity) allows you to do this: \n\n // Entity employee = ...;\n EmbeddedEntity embeddedContactInfo = new EmbeddedEntity();\n\n embeddedContactInfo.setProperty(\"homeAddress\", \"123 Fake St, Made, UP 45678\");\n embeddedContactInfo.setProperty(\"phoneNumber\", \"555-555-5555\");\n embeddedContactInfo.setProperty(\"emailAddress\", \"test@example.com\");\n\n employee.setProperty(\"contactInfo\", embeddedContactInfo);\n\nProperties of an embedded entity are not indexed and cannot be used in queries. You can optionally associate a key with an embedded entity, but (unlike a full-fledged entity) the key is not required and, even if present, cannot be used to retrieve the entity.\n\nInstead of populating the embedded entity's properties manually, you can use the [`setPropertiesFrom()`](/appengine/docs/legacy/standard/java/javadoc/com/google/appengine/api/datastore/PropertyContainer#setPropertiesFrom-com.google.appengine.api.datastore.PropertyContainer-) method to copy them from an existing entity: \n\n // Entity employee = ...;\n // Entity contactInfo = ...;\n EmbeddedEntity embeddedContactInfo = new EmbeddedEntity();\n\n embeddedContactInfo.setKey(contactInfo.getKey()); // Optional, used so we can recover original.\n embeddedContactInfo.setPropertiesFrom(contactInfo);\n\n employee.setProperty(\"contactInfo\", embeddedContactInfo);\n\nYou can later use the same method to recover the original entity from the embedded entity: \n\n Entity employee = datastore.get(employeeKey);\n EmbeddedEntity embeddedContactInfo = (EmbeddedEntity) employee.getProperty(\"contactInfo\");\n\n Key infoKey = embeddedContactInfo.getKey();\n Entity contactInfo = new Entity(infoKey);\n contactInfo.setPropertiesFrom(embeddedContactInfo);\n\nUsing an empty list\n-------------------\n\nDatastore historically did not have a representation for a\nproperty representing an empty list. The Java SDK worked around this by storing\nempty collections as null values, so there is no way to distinguish between null\nvalues and empty lists. To maintain backward compatibility, this remains the\ndefault behavior, synopsized as follows:\n\n- Null properties are written as null to Datastore\n- Empty collections are written as null to Datastore\n- A null is read as null from Datastore\n- An empty collection is read as null.\n\n| **Important:** A read modify write of an entity with an empty list will cause that list to be turned into a null value.\n\nHowever, if you change the default behavior, the Appengine Datastore Java SDK will support storage\nof empty lists. **We recommend you consider the implications of\nchanging the default behavior of your application and then turn on support\nfor empty lists**.\n\nTo change default behavior so you can use empty lists, set the\n[DATASTORE_EMPTY_LIST_SUPPORT](/appengine/docs/legacy/standard/java/javadoc/com/google/appengine/api/datastore/DatastoreServiceConfig#DATASTORE_EMPTY_LIST_SUPPORT)\nproperty during your app initialization as follows: \n\n System.setProperty(DatastoreServiceConfig.DATASTORE_EMPTY_LIST_SUPPORT, Boolean.TRUE.toString());\n\nWith this property set to `true` as shown above:\n\n- Null properties are written as null to Datastore\n- Empty collections are written as an empty list to Datastore\n- A null is read as null from Datastore\n- When reading from Datastore an empty list is returned as an empty Collection.\n\n| **Important:** Your queries might be affected when you turn on empty list support. Null values are indexed in Datastore but empty lists are not. If you were storing empty lists as nulls and then querying for null to find them, then changing to empty list will cause these queries to not return results."]]