ElementCollection representation in class diagram

29 views
Skip to first unread message

Phillip Pimenta

unread,
Oct 2, 2020, 10:09:17 PM10/2/20
to UML Forum
Hi everyone, everything fine?

How I represent an element collection relationship in a class diagram. Example of what I want to represent in UML

public enum CategoryPerson {

    CLIENT,

    EMPLOYEE,

    PROVIDER;

}

public class Person {

    private Integer personId ;

    private String name;

        @ElementCollection
        @CollectionTable (name = "categories_people", joinColumns = @JoinColumn (name = "person_id"))
        @Enumerated (EnumType.STRING)
        @Column (name = "category_person")
    Private list <CategoryPeople> categoriesPeople;
}

Simon Wright

unread,
Nov 4, 2020, 3:38:30 AM11/4/20
to UML Forum
To me, having a class Person in a class model implies that the implementation will include some sort of collection of Persons. I certainly wouldn’t want to clutter the model by including that collection.
Different implementations might well use different kinds of collection.

Just guessing on the domain you’re modelling (perhaps a flower shop?), I’d think that not all Clients would be Persons (you’d hope some would be businesses); and the same goes for Suppliers. There’s information about Suppliers that would be quite inappropriate for Clients, and vice versa. Also, come to think, you don’t have either on your payroll; though some might be both Client and Supplier. That sounds to me like associations between the various entities, maybe? and Products, and Orders?

Reply all
Reply to author
Forward
0 new messages