Skip to content
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

Hibernate ORM guide examples / quickstart are more complex than they should be #45715

Open
yrodiere opened this issue Jan 20, 2025 · 2 comments
Labels
area/hibernate-orm Hibernate ORM area/housekeeping Issue type for generalized tasks not related to bugs or enhancements good first issue Good for newcomers

Comments

@yrodiere
Copy link
Member

yrodiere commented Jan 20, 2025

Description

Creating this issue to collect a few pre-existing problems I noticed while reviewing https://github.com/quarkusio/quarkus-quickstarts/pull/1493/files ; fixing them will conflict with that PR, so it'll have to wait a bit.

Most of these comments apply to all Hibernate ORM quickstarts, with the possible exception of the Panache ones.

  1. Fruit entities use complex configuration for their ID, with custom allocation size, initial value, etc. This should be used instead, it's enough for a simple quickstart:
    @Id
    @GeneratedValue
    private Integer id;
  1. Related to 1. (because the problem will become critical after fixing 1.): some Flyway SQL scripts are using hardcoded IDs, but do not reset the ID sequence at the end of the script. They should include something like ALTER SEQUENCE known_fruits_id_seq RESTART WITH 4; (with proper prefixing of known_fruits_id_seq with a schema name if relevant). See for example how it's done here: https://github.com/quarkusio/quarkus-quickstarts/blob/1cce4732bad55733c9208296d2a3e18ae0abf906/hibernate-orm-quickstart/src/main/resources/import.sql
  2. application.properties files are way too complex:
    1. There shouldn't be anything related to secondary concerns such as logging levels, native-image-xmx, jdbc.max-size/jdbc.min-size.
    2. The db-kind should not be configured explicitly, since it's inferred automatically from the classpath when there's only one JDBC driver.
    3. quarkus.datasource.jdbc.url , quarkus.datasource.username , and quarkus.datasource.jdbc.password should at least be prefixed with %prod. (to limit them to production mode), and IMO should be at the end of the file, and should be accompanied with an override of the quarkus.hibernate-orm.database.generation to create for convenience. Something like what we have in the Hibernate Search docs/quickstart: https://quarkus.io/guides/hibernate-search-orm-elasticsearch#configuring-the-application (without the db-kind...)
      IMPORTANT: If you fix this in quickstarts, don't forget to update the docs to stay consistent, since the docs have copy-pasted examples taken from quickstarts. See https://github.com/quarkusio/quarkus/blob/df602e0adea2e46006aeab636c3d5b25d2eb44ee/docs/src/main/asciidoc/hibernate-orm.adoc

Implementation ideas

No response

@yrodiere yrodiere added area/hibernate-orm Hibernate ORM area/housekeeping Issue type for generalized tasks not related to bugs or enhancements good first issue Good for newcomers labels Jan 20, 2025
@gsmet
Copy link
Member

gsmet commented Jan 20, 2025

I think it would also be a good opportunity to split the guide in two, making it a true getting started guide with the usual template and a separate reference guide.

@yrodiere
Copy link
Member Author

yrodiere commented Jan 20, 2025

I think it would also be a good opportunity to split the guide in two, making it a true getting started guide with the usual template and a separate reference guide.

I agree with this in principle, though it seems to expand the scope significantly (especially for a "good first issue"). Also, do you have an example of an extension that does this correctly, for reference?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/hibernate-orm Hibernate ORM area/housekeeping Issue type for generalized tasks not related to bugs or enhancements good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants