Jones (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
) *commented* on HHH-15772 (
https://hibernate.atlassian.net/browse/HHH-15772?atlOrigin=eyJpIjoiZDVlNj...
)
Re: deprecate @Target, @Proxy, @Polymorphism (
https://hibernate.atlassian.net/browse/HHH-15772?atlOrigin=eyJpIjoiZDVlNj...
)
Given the following snippet:
List<MyEntity> entities = query.list();
for (MyEntity entity : entities) {
// some business logic
for (OtherEntity relatedEntity : entity.getRelationshipEntities() /* polymorphic */ ) {
if (relatedEntity instanceof ConcreteEntityOne) { // this instanceof doesn't work
because sometimes it could be a proxy
// do something
}
}
}
That will need to be changed to something like:
List<MyEntity> entities = query.list();
for(MyEntity entity : entities) {
// some business logic
for (OtherEntity relatedEntity : entity.getRelationshipEntities() /* polymorphic */) {
OtherEntity unproxiedRelatedEntity = Hibernate.unproxy(relatedEntity);
if (unproxiedRelatedEntity instanceof ConcreteEntityOne) { // this instanceof
doesn't work because sometimes it could be a proxy
// do something
}
}
}
To avoid such thing being spread all over the place, then the only other way would be to
have a hibernate listener that will unproxy the loaded entity and it will be in a single
place… So, if I’m initializing a collection of a polymorphic entity, I’ll need to unproxy
its elements.
(
https://hibernate.atlassian.net/browse/HHH-15772#add-comment?atlOrigin=ey...
) Add Comment (
https://hibernate.atlassian.net/browse/HHH-15772#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#100217- sha1:45db922 )