I started using factory methods in JPA Entity classes. But I’m not sure if it’s an anti-pattern. If it is , then where do I place them instead ?
A similar sample is below
@Builder
@Entity
Class EntityA {
public static EntityA fromSomeClass(SomeClass sc){
return builder.id(sc.id).name(sc.name).build();
}
public static EntityA fromAnotherClass(AnotherClass ac){
builder.id(ac.id).name(ac.name).somethingACSpecific("xyz").build();
}
}
12