Skip to content

Conversation

@cchacin
Copy link

@cchacin cchacin commented Nov 29, 2025

Add missing annotations required for the examples to work properly:

  • @GeneratedValue(strategy = GenerationType.IDENTITY) for auto-incremental id
  • @Transactional for the DELETE endpoint to work

Add missing annotations required for the examples to work properly:
- `@GeneratedValue(strategy = GenerationType.IDENTITY)` for auto-incremental id
- `@Transactional` for the `DELETE` endpoint to work
@ttelang
Copy link
Contributor

ttelang commented Jan 18, 2026

  • @GeneratedValue(strategy = GenerationType.IDENTITY) for auto-incremental id

In this tutorial, we intentionally use @GeneratedValue without an explicit strategy:

@Id
@GeneratedValue
private Long id;

This is equivalent to GenerationType.AUTO and delegates the decision to the Jakarta Persistence provider (Hibernate/OpenJPA/etc.), which selects the most suitable mechanism for the configured database.

The provider defaults are as below:

  • SEQUENCE for DBs that support sequences (PostgreSQL/Oracle)
  • IDENTITY for auto-increment DBs (MySQL/MariaDB)
  • TABLE as a fallback where sequences/identity are unavailable

This choice improves the portability of the tutorial because the same examples can run across different databases without forcing an ID strategy that may not exist.

@ttelang
Copy link
Contributor

ttelang commented Jan 18, 2026

In this tutorial, we intentionally use @GeneratedValue without an explicit strategy:

@Id
@GeneratedValue
private Long id;

This is equivalent to GenerationType.AUTO and delegates the decision to the Jakarta Persistence provider (Hibernate/OpenJPA/etc.), which selects the most suitable mechanism for the configured database.

The provider defaults are as below:

  • SEQUENCE for DBs that support sequences (PostgreSQL/Oracle)
  • IDENTITY for auto-increment DBs (MySQL/MariaDB)
  • TABLE as a fallback where sequences/identity are unavailable

This choice improves the portability of the tutorial because the same examples can run across different databases without forcing an ID strategy that may not exist.

I would add the above explanation as a note in the README.adoc file via a separate PR so that other developer understand why no explicit strategy was mentioned.

@ttelang
Copy link
Contributor

ttelang commented Jan 18, 2026

  • @Transactional for the DELETE endpoint to work

@Transactional was not used, as this implementation uses in-memory implementation. You are also right; as an enterprise best practice, I should have used @transactional for all mutating operations, as the intent here is to move to the database going forward.

I would be updating the code via a separate PR at appropriate places.

@ttelang
Copy link
Contributor

ttelang commented Jan 18, 2026

Add missing annotations required for the examples to work properly:

  • @GeneratedValue(strategy = GenerationType.IDENTITY) for auto-incremental id
  • @Transactional for the DELETE endpoint to work

The examples have been tested thoroughly and are working properly without these annotations.

See my earlier comments for an explanation of why the above annotations was not added in the code examples.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants