|
You would need to add handling to the actual reading of a composite out of the ResultSet to handle all tuples as null to mean "create an empty composite instance". That's how "loaded state" is populated. This would require changing org.hibernate.type.ComponentType#resolve from:
@Override
public Object resolve(Object value, SessionImplementor session, Object owner) {
if ( value != null ) {
...
}
else {
return null;
}
}
to something like:
@Override
public Object resolve(Object value, SessionImplementor session, Object owner) {
if ( value != null ) {
...
}
else {
return createEmptyCompositesEnabled() ? instantiate( owner, session ) : null;
}
}
You'd also need to make certain that this is accounted for in the various equality checking methods (isSame, isEqual, compare, isModified, etc).
Also this will require lots of testing as this is a long standing assumption in Hibernate code.
Ultimately this is very low on my todo list. But if someone wants to work on it and work up a Pull Request, that obviously raises the likelihood that it gets resolved sooner. I laid out the main changes above. Just make sure that createEmptyCompositesEnabled():
-
delegates to SessionFactory/Settings
-
is fueled by a user-controlled setting
-
is disabled by default (opt-in behavior)
|