[hibernate-dev] HHH-7610 Embedded: emptiness and dirtiness

Steve Ebersole steve at hibernate.org
Fri Oct 24 09:08:11 EDT 2014


Hi Guillaume,

In general, yes, there is interest in this.  I think quite a few folks have
asked for it, so certainly it would be nice to make it an option.  We've
all just been busy lately.

As to your specific question, yes I think what you propose makes sense.
Namely, if this setting is enabled, I think it is reasonable to treat a
null component reference and an empty component reference as equivalent.

You are probably aware, but I just wanted to caution you that this solution
as-is makes a not-necessarily-true assumption that this
"hibernate.create_empty_composites.enabled" setting is set when the
Component is created.  This is a general design problem with complete
open-ended-ness of the Configuration object.  There really is not a way
around that in the 4.x code base as it currently sits.  Just pointing out
that this solution is dependent on order of calls to the Configuration
object.

Also, a minor point, but the if-statement to
set ComponentMetamodel#createEmptyCompositesEnabled should be simplified.
I added a line note to commit.

On Mon, Oct 20, 2014 at 4:08 AM, Guillaume Smet <guillaume.smet at gmail.com>
wrote:

> Hi!
>
> Any interest in us pursuing this?
>
> We are obviously committed to update the documentation once we have
> validated it's the way to go.
>
> Thanks for your feedback.
>
> On Tue, Oct 14, 2014 at 3:23 PM, Guillaume Smet
> <guillaume.smet at gmail.com> wrote:
> > Hi all,
> >
> > So, after a long time without any issue (rest assured we were busy
> > anyway!), we got around a new problem we would like to fix in ORM:
> > HHH-7610 .
> >
> > It's a long standing complaint about the embedded and the fact that
> > empty components are returned from the ORM.
> >
> > We had the "good" idea to fix it by overriding the getter to set the
> > value to an empty object if null and it's not really a good one: we do
> > a lot of unnecessary updates due to the fact that our entities are
> > considered dirty.
> >
> > A coworker of mine (Laurent CCed) followed the instructions given by
> > Steve in HHH-7610 to implement a configuration setting to return an
> > empty component if all its properties is null:
> > see
> https://github.com/openwide-java/hibernate-orm/commit/a219fd38c0a80e6bf0a5de41f31e49ee83f00ccf
> > -> we think this one should be ready to commit. It's for 4.3.x.
> > -> using all the tests with this new setting enabled triggers a few
> > errors but, after carefully reviewing them, they are all expected due
> > to the nature of this change.
> >
> > We are wondering if we shouldn't also change the isDirty/equals...
> > stuff to consider 2 components equals if one is null and the other has
> > all its properties null: it sounds kinda logical to us considering ORM
> > already automatically transforms one to the other if we save then get
> > the entity.
> >
> > We wrote a few tests to demonstrate the issue and we would like to
> > know if you would consider this a good idea or not to fix this in both
> > cases (settings on or off):
> >
> https://github.com/openwide-java/hibernate-orm/commit/ee913e79633d3a5ac9c5affdcb58ab3af780f71a
> >
> > Thanks for your advice.
> >
> > --
> > Guillaume
> _______________________________________________
> hibernate-dev mailing list
> hibernate-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/hibernate-dev
>


More information about the hibernate-dev mailing list