| I have a Game class { @ManyToOne @JoinColumn("homeTeamId") private Team homeTeam; @ManyToOne @JoinColumn("visitorTeamId") private Team visitorTeam; } I am trying to create additional relationships from the Game to the score for the home team and the score for the visitor team (may or may not exist) The table for Score is gameId, teamId, note, score (it's not an option to fix the schema) So I need to write a @JoinFormula that uses the gameId and the homeTeamId similar to this @ManyToOne @JoinFormula("(SELECT _s.id FROM Scores _s WHERE _s.teamId = homeTeamId AND _s.gameId = id)") private Score homeScore; @ManyToOne @JoinFormula("(SELECT _s.id FROM Scores _s WHERE _s.teamId = visitorTeamId AND _s.gameId = id)") private Score visitorScore; Without these additional attributes, homeTeam and visitorTeam are initialized properly When I add one of the formula manytoone score attributes I see the attached screenshot in the debugger - the team is not initialized while the game score is initialized |