Say I have these two models:
public class City extends Model
{
@ManyToOne
private Country country;
}
public class Country extends Model
{
}
I have a City object and want to know the related Country's ID. I could fetch from the database by doing city.getCountry().getId()
but that seems very wasteful. How can I just get the ID (stored in the database table as country_id
)?