[hibernate-dev] api/doc suggestions
Sanne Grinovero
sanne at hibernate.org
Thu Feb 20 06:58:28 EST 2020
On Wed, 19 Feb 2020 at 23:42, Max Rydahl Andersen <manderse at redhat.com> wrote:
>
> Finally figure out my atlassian account so i could go with the hibernate
> issues ;)
>
> >> What is the equivalent way to do this in new metadata api:
> >>
> >> ```
> >> new Configuration().setProperty("hibernate.dialect",
> >> "org.hibernate.dialect.H2Dialect")
> >> .setProperty("hibernate.connection.url",
> >> "jdbc:h2:./sakila")
> >> .setProperty("hibernate.connection.username",
> >> "sa")
> >> .buildSessionFactory();
> >> ```
> >>
> >> Just setup dialect, give connection info and get a
> >> sessionfactory/entitymanager ?
> >>
> >> I found apis to start from a file containing those settings; but I
> >> really just want a programmatic api
> >> to use in batch script etc. without a need for external files.
> >
> > Agreed we should explore making the "frameworkless bootstrap" simpler;
> > booting the ORM today requires some expertise, resulting in people to
> > rely on other frameworks to do the job.
>
> I think documentation could go a long way - I couldn't find anywhere
> in the docs the minimal step for configuring hibernate programmatically.
> All seem to assume you have external files for it.
>
> > However, the possible configuration options we have today are
> > significant; there's good reasons to have them so while an helper
> > would be welcome, I don't expect we'll want to change or simplify the
> > existing boot code, as it's working and doing a great job. This would
> > rather provide a simple, limited alternative.
> >
> > It will be necessary to clarify that the "simple" alternative is also
> > very limiting: for example I could see myself volunteering to create
> > such a little toy, but don't expect it to work in modular
> > environments, containers, pick up transaction managers, integrate with
> > DI frameworks, allow for Datasource injection, etc. etc.. Ok?
>
> well, maybe the existing Configuration api is that "toy" already ?
>
> > A consequence of such limitations would be that runtime performance
> > and efficiency would also be limited; let's be upfront about the
> > intent in the API documentation.
> >
> > I can try toy with a POC but can't promise a quick turnaround on this
> > one; not least I'd need Steve's blessing and review:
> > - https://hibernate.atlassian.net/browse/HHH-13862
> >
> > Please comment on the JIRA or send a PR if you have a more concrete
> > idea or a draft.
>
> will do - but I don't have much to add for now....looking forward to see
> what Steve thinks on this.
+1 me too.
I have sketched a POC for that; but had to put it aside for now, would
be good to know if it's worth me spending more time on it.
It's not hard but I wonder:
- how to get a good balance of simple and limited but useful enough
for "simple things"
- will we want such a thing to be part of ORM proper, and which package
Main problem is the definition of "simple things" is not very
specific. Secondarily, wouldn't want to have the more limited approach
look like the recommended approach.
Normally we face such issues iteratively: start with the basics, and
enhance according to demand; but in this case I'd prefer to make sure
it doesn't get out of hand: would rather set a precise goal upfront
and stick to it.
For example: my POC only exposes setting configuration elements via
`setProperty(String, String)`; that might be good enough for you but
it implies one can't even inject a Datasource instance - I'm inclined
to think people will have to accept such limitations, or be steered
towards using the existing more powerful bootstrap API.
Another aspect: Quarkus intentionally disables some steps of the ORM
bootstrap process, as it knows its own environment e.g. classloader
structure - this gives it a kick in terms of boot times and memory
use; It would be tempting to expose some form of "explicit
programmatic profiles" that could give similar benefits to all users.
For example a useful profile could be one for Java SE users having a
flat classloader and just needing to run some quick in-memory tests on
H2.
Thanks
>
> >> Here again, the ask is so we can educate and point people to use
> >> statelessSession rather than dropping Hibernate fully and from that
> >> api if needed go do `.doWork()` rather than refer to deprecated
> >> `.connection()`
> >
> > Makes sense, I believe we should be able to do this quickly:
> > - https://hibernate.atlassian.net/browse/HHH-13861
> >
> > Andrea volunteered to have a look; assigned to him assuming it's
> > straight forward; if it gets tricky we'll have to wait for Steve's
> > opinion.
> >
>
> that one is now fixed and that’s awesome. one less deprecation I'm
> forced to use :)
>
More information about the hibernate-dev
mailing list