For example, there is an entity “User” with @ManyToOne(fetch=Lazy) field “Team”. I have used entityManager.find(User.class, userId) get a user. At this point, if I call user.getTeam() a query will be send to database to get team object. Is there a way to get the team id without extra query?
For example, there is an entity User with @ManyToOne(fetch=Lazy) field Team. I have used
Share
For these purposes I do map the column twice. Once as many-to-one with
insert="true"andupdate="true".then I append an TeamId property and mapp it as int
insert="false"andupdate="false". Instead ofcolumnmapping I useformula.TeamId is then available after the first select.