Architecture Officer - Goal

1

The doubt I have is totally architectural. I'll expose a case just below to better illustrate the doubt that I'm hitting directly on my system.

I have a feature that aims to register an employee. Such an employee is composed of basic fields like name, surname, date of birth, function and etc ... OK! So far we do not have any problem, but this employee has associated with him the sales targets that must fulfill, that is, in each month of the year I have a value "trailer".

If we imagine the relationship between such entities, then I created something like this:

An employee has many goals, which in turn have the months of the year.

Below are bean's reduced form:

public class Funcionario implements Serializable {

        private static final long serialVersionUID = 1L;

        @Id
        @GeneratedValue(strategy = GenerationType.IDENTITY)
        private Long id;

        @OneToOne(cascade = CascadeType.PERSIST)
        @JoinColumn(name = "fk_metas")
        private Meta metas;

        ///Getters and Setters
}

public class Meta implements Serializable {

    private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    private String ano;

    @OneToMany(cascade = CascadeType.PERSIST, mappedBy = "metas")
    private Set<Mes> meses;

    ///Getters and Setters
}

public class Mes implements Serializable {
    private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @ManyToOne
    @JoinColumn(name="fk_ano")
    private Meta metas;

    private Double janeiro;

    private Double fevereiro;

    ///Getters and Setters... Meses restantes
    }

Would that be the smartest way?

    
asked by anonymous 05.05.2015 / 00:49

0 answers