Left Join with EntityViews and where on both sides. #1410
-
Hello I am currently trying to implement a left join in which there are where clauses on both sides. In SQL I managed to get it to work as follows: I figured, I should use a correlation mapping to map the subview, in this case the Bet into the Game. What I am missing, is to have a query on that correlation mapper, that allows me to only join when a specific criteria is met. As I am using a criteria builder that has the entity Game as its root element, I am unable to add a clause for Bet. Game does not have any knowledge of Bet in this context. Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 10 replies
-
I suppose you are not used to the join condition semantics of the various join types as it seems that what you want is a simple query like this:
For every row from Since implicit joins in Blaze-Persistence are left joins by default, you can make use of the array expression syntax in entity views which translates to the join condition: @EntityView(Game.class)
interface GameView {
@Mapping("Bet[game = EMBEDDING_VIEW() AND betterId = 1]")
BetView getBet();
}
@EntityView(Bet.class)
interface BetView {
...
} |
Beta Was this translation helpful? Give feedback.
-
Thanks! It seems to work as I expected it. I had to change from EMBEDDING_VIEW() to VIEW_ROOT() as I would get an exception. I also introduced a parameter. Regards |
Beta Was this translation helpful? Give feedback.
Thanks!
It seems to work as I expected it.
I had to change from EMBEDDING_VIEW() to VIEW_ROOT() as I would get an exception. I also introduced a parameter.
@Mapping("Bet[game = VIEW_ROOT() AND better.id = :betterId]")
Does this make sense to you?
Regards