François Rosière (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
) *updated* an issue
Hibernate ORM (
https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiZTFkOGUxYTU0...
) / Improvement (
https://hibernate.atlassian.net/browse/HHH-16550?atlOrigin=eyJpIjoiZTFkOG...
) HHH-16550 (
https://hibernate.atlassian.net/browse/HHH-16550?atlOrigin=eyJpIjoiZTFkOG...
) Allow accessing the entity identifier from the UserType#nullSafeSet method (
https://hibernate.atlassian.net/browse/HHH-16550?atlOrigin=eyJpIjoiZTFkOG...
)
Change By: François Rosière (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
)
Hibernate currently provides a way to define custom types. Either internal or user types.
In some situations, this custom type may have to access the entity identifier.
Concrete use case: compute a custom value using the entity identifier (may be null
depending on the id strategy which is used).
This is currently possible from the nullSafeGet method through the owner but this is not
possible to access that identifier from the nullSafeSet Method.
So, the proposal would be to review the Hibernate internals to allow exposing this
identifier as follow on the UserType interface and call this new method instead of the
current one
{code:java}public interface UserType {
// hibernate would call this method internally
// id parameter is the owner/entity identifier
default void nullSafeSet(PreparedStatement st, Serializable id, Object value, int index,
SharedSessionContractImplementor session) throws HibernateException, SQLException {
nullSafeSet(st, value, index, session);
}
void nullSafeSet(PreparedStatement st, Object value, int index,
SharedSessionContractImplementor session) throws HibernateException, SQLException;
}{code}
The Type interface would also need to be updated the same way to allow transmitting the id
from the caller stack. See CustomType.
Proposed change is retro-compatible.
(
https://hibernate.atlassian.net/browse/HHH-16550#add-comment?atlOrigin=ey...
) Add Comment (
https://hibernate.atlassian.net/browse/HHH-16550#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#100225- sha1:f83bc8f )