0

I have two objects in my model:

@Entity
@Table(name = "project")
@Getter
@Setter
public class Project extends BaseData{
    ...
    private PaymentMethod paymentMethod;
    ...
}

.

@Getter
@Setter
public class PaymentMethod {
    private Boolean requestRequired;
    private Integer timeLimit;
}

What I want to do is to map requestRequred and timeLimit fields on columns of project table so there is no need to create one more table to store PaymentMethod objects in.

Is it possible in general and is it a common practice to do this? It seems a little bit counterintuitive for me and difficult to maintain. But on the other side a lot of tables lead to performance issues as far as I know.

Thanks for help!

alexbt
  • 16,415
  • 6
  • 78
  • 87
mr.nothing
  • 5,141
  • 10
  • 53
  • 77
  • 2
    You're looking for `@Embeddable` and `@Embedded`. You can find many questions (and answers) about them here and elsewhere. For example, [When to use @Embedded and @Embeddable?](https://stackoverflow.com/q/35174981/2402272), [Why do we use @Embeddable In Hibernate?](https://stackoverflow.com/q/19341838/2402272), and [What is difference between @Entity and @embeddable?](https://stackoverflow.com/q/21143707/2402272). – John Bollinger Jun 27 '17 at 17:48
  • @JohnBollinger, Oh, thanks, it is exactly what I need. Post it as a answer please, so I can accept it. – mr.nothing Jun 28 '17 at 11:37

0 Answers0