Re: [hibernate-dev] Hibernate Rx: Remove Optional from API

2020-04-16 Thread Steve Ebersole
Bit off track, but since you mentioned load, etc... Take a look at
the IdentifierLoadAccess, etc variants for loading.  E.g.

interface IdentifierLoadAccess {
T getReference(Object id);
T load(Object id);
Optional loadOptional(Object id);
}

Granted I'm partial, but I think that's pretty clear :)

Reactive stuff is a bit different, but from my experience I would never
ever ever use something like `Optional` for an
association.  In fact back in the day this was more/less what Top Link did
for to-one mappings and it was fugly.  Not that you are suggesting that
per-se.


On Thu, Apr 16, 2020 at 9:11 AM Sanne Grinovero  wrote:

> I would agree with you all about the general sentiment against the use
> of Optional, but there's one use case in which I think it might make
> sense (although bear with me as I've never really used it much yet) :
>
> there's several methods on the standard Session and EntityManager in
> Hibernate ORM to fetch a single entity: load/find/get/...
>
> Even after all these years, I always have to open the Javadoc to
> remember which ones are making assumptions about the entity existence
> in the database (so could return a proxy even if the object doesn't
> actually existin the DB), and which ones are going to check first in
> the DB, possibly returning null.
>
> Wouldn't Optional be great there to express the doubt vs the certainty
> of it returning something?
>
> Similarly in xToOne associations, having to remember to set the
> "optional" attribute, or having business code having to match the
> mapping is not ideal. That's perhaps unrelated, as this second point
> is more about how users should express mappings rather than how we
> expose APIs, but I mean it as an example to not necessarily go to the
> extreme of ignoring that it might have some use in some selected
> cases.
>
> Thanks,
> Sanne
>
> On Thu, 16 Apr 2020 at 11:44, Davide D'Alto  wrote:
> >
> > Hi,
> > Gavin sent this PR: https://github.com/hibernate/hibernate-rx/pull/93
> >
> > It removes Optional from the API, for example:
> >
> >  CompletionStage> fetch(T association);
> >
> > becomes:
> >
> >  CompletionStage fetch(T association);
> >
> > Is there anybody here with strong opinions about keeping Optional in the
> > API?
> >
> > Thanks,
> > Davide
> > ___
> > hibernate-dev mailing list
> > hibernate-dev@lists.jboss.org
> > https://lists.jboss.org/mailman/listinfo/hibernate-dev
> >
> ___
> hibernate-dev mailing list
> hibernate-dev@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/hibernate-dev
>
>
___
hibernate-dev mailing list
hibernate-dev@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/hibernate-dev


Re: [hibernate-dev] Hibernate Rx: Remove Optional from API

2020-04-16 Thread Sanne Grinovero
I would agree with you all about the general sentiment against the use
of Optional, but there's one use case in which I think it might make
sense (although bear with me as I've never really used it much yet) :

there's several methods on the standard Session and EntityManager in
Hibernate ORM to fetch a single entity: load/find/get/...

Even after all these years, I always have to open the Javadoc to
remember which ones are making assumptions about the entity existence
in the database (so could return a proxy even if the object doesn't
actually existin the DB), and which ones are going to check first in
the DB, possibly returning null.

Wouldn't Optional be great there to express the doubt vs the certainty
of it returning something?

Similarly in xToOne associations, having to remember to set the
"optional" attribute, or having business code having to match the
mapping is not ideal. That's perhaps unrelated, as this second point
is more about how users should express mappings rather than how we
expose APIs, but I mean it as an example to not necessarily go to the
extreme of ignoring that it might have some use in some selected
cases.

Thanks,
Sanne

On Thu, 16 Apr 2020 at 11:44, Davide D'Alto  wrote:
>
> Hi,
> Gavin sent this PR: https://github.com/hibernate/hibernate-rx/pull/93
>
> It removes Optional from the API, for example:
>
>  CompletionStage> fetch(T association);
>
> becomes:
>
>  CompletionStage fetch(T association);
>
> Is there anybody here with strong opinions about keeping Optional in the
> API?
>
> Thanks,
> Davide
> ___
> hibernate-dev mailing list
> hibernate-dev@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/hibernate-dev
>
___
hibernate-dev mailing list
hibernate-dev@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/hibernate-dev


[hibernate-dev] Hibernate Rx: Remove Optional from API

2020-04-16 Thread Davide D'Alto
Hi,
Gavin sent this PR: https://github.com/hibernate/hibernate-rx/pull/93

It removes Optional from the API, for example:

 CompletionStage> fetch(T association);

becomes:

 CompletionStage fetch(T association);

Is there anybody here with strong opinions about keeping Optional in the
API?

Thanks,
Davide
___
hibernate-dev mailing list
hibernate-dev@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/hibernate-dev