jakartaee / persistence

https://jakartaee.github.io/persistence/
Other
203 stars 59 forks source link

add Finder interface #436

Closed gavinking closed 1 year ago

gavinking commented 1 year ago

Draft proposal for a new Finder interface allowing typesafe passing of caching and locking options and an EntityGraph.

see #383

trajano commented 1 year ago

What happens when both loadGraph and fetchGraph are provided? If we only allow one then

with(EntityGraph eg, EntityGraphLoadType loadOrFetch)
gavinking commented 1 year ago

What happens when both loadGraph and fetchGraph are provided?

Well, what happens today if you specify both hints? The semantics should be the same, I guess.

gavinking commented 1 year ago

[P.S. Please compare this to #415 which has slightly different naming conventions.]

trajano commented 1 year ago

What happens when both loadGraph and fetchGraph are provided?

Well, what happens today if you specify both hints? The semantics should be the same, I guess.

Correct, that semantic should be defined or be made explicit. It does not make sense to have both of them and the behaviour is presently undefined.

I'd like to change the proposal though to reverse the parameter order

with(EntityGraphLoadType loadOrFetch, EntityGraph eg)

So when people code it

.with(FETCH, myEntityGraph)
.with(LOAD, myEntityGraph);

And explicitly state to prevent ambiguity that the later of the two with will win.

gavinking commented 1 year ago

So that makes perfect sense, but personally I find it really quite a lot less ergonomic. IDEs do a somewhat better job of completing enum values than in the past, but even so I really find that they still get in the way and disrupt my "flow" when I'm typing this kind of code.