tailieunhanh - Apress bắt đầu ứng dụng với java google - p 17

Key: Một giá trị bao gồm các phím của bất kỳ nhóm phụ huynh thực thể đang được sử dụng và chuỗi một ID ứng dụng tạo ra hoặc một ID systemgenerated số. 4. Chính là mã hóa String: Về cơ bản, một khoá mã hoá để đảm bảo tính di động và vẫn cho phép ứng dụng của bạn để tận dụng lợi thế của các nhóm thực thể của Bigtable. | CHAPTER 7 USING THE APP ENGINE DATASTORE 3. Key A value that includes the key of any entity-group parent that is being used and an application-generated string ID or a systemgenerated numeric ID. 4. Key as Encoded String Essentially an encoded key to ensure portability and still allow your application to take advantage of Bigtable s entity groups. If you want to implement your own key system you simply use the createKey static method of the KeyFactory class. You pass the method the kind and either an application-assigned string or a system-assigned number and the method returns the appropriate Key instance. So to create a key for an Order entity with the key name jeff@ you would use Key key jeff@ Note If your implementation inadvertently creates a duplicate key for your entity this new entity will overwrite the existing entity in the datastore. Listing 7-1 is an example JDO class with an automatically generated Long ID provided by Bigtable with both persisted and non-persisted fields. The phone member is only available within the scope of the object and is not persisted to the database. Entities created from a database call will contain a null value for the phone member. Listing 7-1. Sample JDO POJO import import import import import import Declares the class as capable of being stored and retrieved with JDO @PersistenceCapable identityType public class Contact Required primary key populated automatically by JDO @PrimaryKey 138 CHAPTER 7 USING THE APP ENGINE DATASTORE @Persistent valuestrategy private Long id @Persistent private String name Field NOT persisted to the datastore @NotPersistent private String phone public Contact .