I am using Java Spring and have a model that I am currently mapping to both a Relational Database (MySQL) and a NoSQL Database (MongoDB).
@Entity
@Document
public class Person {
@Id
@AutoGenerated(...)
private long id;
@Id
private String documentId;
private String firstName;
private String lastName;
...
}
I need the relational model's id to be a long while and the non-relation model to be a String. I am unsure if duplicated '@Id' annotations (even of different types) will cause issues.
Is there a way I can annotate the class to ensure that the model is compatible with JPA and the MongoClient?
Or do I need to create two different classes (PersonDocument, PersonEntity) and convert between the two?