quarkus: Hibernate ORM codestart doesn't compile out of the box, jdbc extension is needed

Describe the bug

Hibernate ORM codestart doesn’t compile out of the box, jdbc extension is needed

Hibernate ORM codestart was introduced in https://github.com/quarkusio/quarkus/pull/20879 by @loicmathieu

Expected behavior

codestart compiles

Actual behavior

codestart doesn’t compile on its own, additional changes are needed

How to Reproduce?

Download sample app with just orm extension selected from https://code.quarkus.io/

Run mvn clean verify

Output of uname -a or ver

No response

Output of java -version

No response

GraalVM version (if different from Java)

No response

Quarkus version or git rev

No response

Build tool (ie. output of mvnw --version or gradlew --version)

No response

Additional information

No response

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 27 (26 by maintainers)

Most upvoted comments

I’ll let @Sanne and @yrodiere decide on this one.

Ok, so I’ll decide: we’ve been arguing for a long time with no decision, we need to move on. Let’s close this.

Two motivations:

  1. Codestarts are a thing whether we like it or not. We could argue about their value, but that ship has sailed. If we provide codestarts, let’s provide them consistently.
  2. Adding a JDBC extension automatically is not possible, because we don’t know which one to add. Better an application that fails and tells you why than an application that takes a decision without you knowing, and may take the wrong decision.

So let’s keep the things as they are, and keep adding codestarts. If people forget to include a JDBC driver, we’ll error out and people will just include a JDBC driver. If the current error is unclear, we’ll improve it.

AFAICS, I’m not the only one with that opinion.

Closing as not planned; thanks everyone involved for the discussion.

So, what is the decision around this issue ? It blocks #21651

My take on it: keep it as today, an error is good and people must add a JDBC driver when using Hibernate.

I will give more thought to that kind of problem when I get back. Still I think it’s ok to fail if it says that a db is required to work, this is the normal order of things.

Most users will have selected a driver at creation time, if they forget, then I think it’s ok to fail telling them the next step.

I’d love to see it handled by our tooling too. But I failed to persuade others into developing a general-purpose technique to have the tooling automatically add dependencies based on rules.

Perhaps it’s time to reopen that topic, as it was partially dismissed also because people were too busy with more important matters. We could try implementing a non-generic solution as an experiment to address at least the ORM case… for example we could have an hardcoded rule that adds H2 to ORM when no other driver is selected.

To be clear, I’m NOT saying I’ll definitely merge such a solution - but that it would be nice to produce such an experiment so to evaluate the option… need to be cautious as I’m afraid this could open a pandora box of things I’ve not considered.

@aloubyansky feel free to shut it down already 😃 Or do you think we could try something among those lines?

I think we are reversing the problem, when the users are getting the hibernate extension alone and start coding, they will end up in the same situation where they need to add a driver. It seems totally healthy to me that codestarts are doing the same.

Most users will already have selected a driver alongside hibernate and it will work out of the box. The few users which will have only selected hibernate will at least have an indicator on the way forward (delete the code, or add the driver).

I think it’s way better to have an application that is not building with good reasons, than an application that is building just to avoid complaining.

I am not against looking for ways to make the user flow more streamlined but I don’t think that removing the code is going in this direction.