-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Have a way to get access to EntityManager even without entities #7148
Comments
It would be even better if you could |
wondering a couple of things:
Besides, having to configure such things IMO defeats the point as you'd get out of the flow of iterative development in live reload: think about the case in which you're introducing Hibernate ORM into a project - IMO such experience needs to be polished and is more important than to support entityless-ORMs.
TBH I wonder how messy this gets. It's certainly far simpler to explain that Hibernate won't be started when there are no entities 😜 |
How "useless' is that that injected EntityManager ? Can I get a statelessSession from it ?
Without having it fail hard at step #3 ? I fully agree to that and in my world view that mimicks the reason why I don't want users having to do step #5 before they can do #6 We'll still require step #4 but that i feel is something that is possible for us to have go error messages and easy for users to grok that acccess data requires a datasource configured. |
see #8348 for issue where this would be relevant for Panache too |
I'm having the same issue with a module that defines a Singleton that offers some generic operations. The entities are defined in the more specific modules. A module/library must not always have a single use. |
Very tangential to this and sorry for hijacking, but I think it's about time we introduced clean new |
@maxandersen @Sanne as promised, a first version of I have not made any changes to conditions under which Hibernate is booted in Quarkus, I just added support for |
StatelessSession implemented but not the part of starting hibernate without entities. |
Did we ever get some documentation for |
@Sanne I think the proposal above from @gastaldi (to activate Hibernate when the Any reason why we should not do it? |
Sure let's do it. I have some minor concerns, which I'll write down so we can think about it, but don't consider these blocking: I hope we can deal with them or accept them as lesser inconvenience. 1# detection based on injection won't give people a consistent behaviour with programmatic lookup. 2# I don't remember if ORM is now able to boot w/o entities. 3# There's for sure going to be some sideffect on other extension's expectations. |
WDYT? |
I wouldn't worry too much and just do it - we'll never know otherwise what problems it might cause. I pushed back about doing such things earlier as the ORM6 migration would have been complex enough w/o having to think about additional side-effects, but that's done... it's a good time to address these aspects too. |
👌 |
Isn't #1 minor issue as most will have entities anyway that will still be able to enable ? I agree with sanne - we should just do it and see it :) |
Yeah, I'll take care of it soon |
Of course it turns out to be easier said then done... Getting the injection points using |
How are those beans configured? It should work fine for synthetic beans. But I suppose that it wouldn't be possible to turn those beans into synthetic ones?
I don't know of any Jandex util but you can query the |
I am not the maintainer of this extension, but I don't think all the beans here can be synthetic. Yeah, I am aware of the lack of inject for constructors, hence the question about the existence of the utility |
We don't have such a utility because it's not the "rigtht" thing to do ;-) |
Yeah, I am aware of what's right and what's not. But the overlap with practicality is not always complete |
After reading #8861 and #31392, I have a question regarding Currently, our workaround is to iterate the list of entities, split them in big "batches" (as big as we consider them "safe and quick to insert") and use "createNativeQuery". We dynamically build and run something like Since we use Ideally we'd like to just call something like If required, I can open a separate issue. Update: or maybe reopen #8348 with this into consideration? |
you can consider to use batch inserts in hibernate then doing persist(iterable) should perform well if done cleanly. but yes, you should be able to do a inserts a bit more "raw" with stateless session. |
I think you have a good point about some use cases not needing the Id to be returned, especially when inserting large batches of data. This has bit myself in the past; normally this can be worked around by using a different ID generation strategy or one of our id generation optimizers, but I think you're right that, especially the Stateless API, could benefit from an improved alternative. Yes @gian1200 , could you open a new issue? Although it would be best to open this one on the Hibernate JIRA or discuss it on the Hibernate zulip chat. @gavinking @beikov opinions ^ ? |
Description
JPA and Hibernate APIs can still be used and be useful without entities( query raw data and using native sql) but for now we don't support @Inject of JPA apis when no entities.
At the moment having to tell users to create a dummy entity to get access to a stateless session is pretty suboptimal :)
Implementation ideas
have a
quarkus.jpa.enable=true|false|auto
property to allow to set totrue
.What do you say @Sanne / @gsmet ? :)
The text was updated successfully, but these errors were encountered: