Christian Beikov (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
) *commented* on HHH-15612 (
https://hibernate.atlassian.net/browse/HHH-15612?atlOrigin=eyJpIjoiODBjMm...
)
Re: Bad SQL generation when using entity graph with ON clause on query (
https://hibernate.atlassian.net/browse/HHH-15612?atlOrigin=eyJpIjoiODBjMm...
)
I just closed this issue that you were referring to, as that was fixed in Hibernate 6.
I don’t know what to tell you. Filtering a collection that you fetch is not safe, that’s
why JPA doesn’t allow assigning an alias to a join fetch. In Hibernate 6, we fixed this
unsafety. If you want to fetch a subset of data, what you need is a projection/DTO for
which there are tools like e.g. Blaze-Persistence Entity-Views (
https://github.com/Blazebit/blaze-persistence#entity-view-usage ) with which you can
select exactly the data that you want.
Your use case could be modeled with entity views like this:
@EntityView(CustomerOrder.class)
public interface CustomerOrderDto {
@IdMapping
Long getId();
@Mapping( "orderPositionCollection[deleted = false ]" )
List<OrderPositionDto> getOrderPositionCollection();
}
@EntityView(OrderPosition.class)
public interface OrderPositionDto {
@IdMapping
Long getId();
Integer getAmount();
ProductDto getProduct();
}
@EntityView(Product.class)
public interface ProductDto {
@IdMapping
Long getId();
String getProductName();
}
(
https://hibernate.atlassian.net/browse/HHH-15612#add-comment?atlOrigin=ey...
) Add Comment (
https://hibernate.atlassian.net/browse/HHH-15612#add-comment?atlOrigin=ey...
)
Get Jira notifications on your phone! Download the Jira Cloud app for Android (
https://play.google.com/store/apps/details?id=com.atlassian.android.jira....
) or iOS (
https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=Em...
) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100209- sha1:392b984 )