persistence@glassfish.java.net

Simple collections

From: Aleksei Valikov <aleksei.valikov_at_gmail.com>
Date: Wed, 30 May 2007 08:31:14 +0200

Hi.

Is there a spec-compliant way to map simple collections?
Like this one:

    public List<String> anyURI;

Currently I have to simulate a collection of entities:

    @OneToMany(cascade = {
        CascadeType.ALL
    })
    public List<SimpleCollectionTypesType.AnyURIItem> anyURIItems;


    @Entity
    @Inheritance(strategy = InheritanceType.JOINED)
    public static class AnyURIItem
        implements Item<String> , Equals, HashCode
    {

        @Basic
        public String value;
        @Id
        @GeneratedValue(strategy = GenerationType.SEQUENCE)
        public Long hjid;

        public boolean equals(Object object) { ... }
        public void hashCode(HashCodeBuilder hashCodeBuilder) {
            hashCodeBuilder.append(this.getValue());
        }

        public int hashCode() { ... }
    }

But this is quite awkward.

Bye.
/lexi