Suppose I have a class MyClass
:
public class MyClass {
@Id
private int id;
@???
private String cityName;
// getters and setters
}
Now I would like my schema to consist of two tables:
- MyClassTable: id INT PRIMARY KEY, city INT FOREIGN KEY ON CityTable.id
- CityTable: id INT PRIMARY KEY, name VARCHAR
Do I have to create a new class for City with two attributes: int Id
and String name
? Is it possible to accomplish this using only the MyClass
class with some special annotation on the cityName
?