小编Cam*_*ron的帖子

如何在Google App Engine(Java)中注释嵌入对象的集合?

是否可以在Google App Engine(Java)中存储嵌入式类的集合?如果是这样,我将如何注释它?

这是我的班级:

@PersistenceCapable
public class Employee
{
    @PrimaryKey
    @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
    Key key;

    @Persistent(embeddedElement = "true")
    private List<ContactInfo> contactDetails = new ArrayList<ContactInfo>();

    public void addContactInfo(String streetAddress, String city)
    {
        this.contactDetails.add(new ContactInfo(streetAddress, city));
    }

    public List<ContactInfo> getContactDetails()
    {
        return this.contactDetails;
    }

    @PersistenceCapable
    @EmbeddedOnly
    public static class ContactInfo
    {
        @Persistent
        private String streetAddress;

        @Persistent
        private String city;

        public ContactInfo(String streetAddress, String city)
        {
            this.streetAddress = streetAddress;
            this.city = city;
        }

        public String getStreetAddress()
        {
            return this.streetAddress;
        }

        public String getCity() …
Run Code Online (Sandbox Code Playgroud)

google-app-engine jdo

5
推荐指数
1
解决办法
1940
查看次数

标签 统计

google-app-engine ×1

jdo ×1