question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Panache Data REST: Update method requires at least two connections

See original GitHub issue

Describe the bug I have a resource called:

public interface ApplicationResource extends PanacheEntityResource<ApplicationEntity, Long> {
}

This endpoint exposes all the REST methods. The problem is that the PUT method (update) requires a minimal of two connections. So, if we limit the amount of connections using this property:

quarkus.datasource.jdbc.max-size=1

The update method will fail with:

Caused by: org.hibernate.exception.GenericJDBCException: Unable to acquire JDBC Connection
	at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:47)
	at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:113)
	at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:99)
	at org.hibernate.resource.jdbc.internal.LogicalConnectionManagedImpl.acquireConnectionIfNeeded(LogicalConnectionManagedImpl.java:111)
	at org.hibernate.resource.jdbc.internal.LogicalConnectionManagedImpl.getPhysicalConnection(LogicalConnectionManagedImpl.java:138)
	at org.hibernate.engine.jdbc.internal.StatementPreparerImpl.connection(StatementPreparerImpl.java:50)
	at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$5.doPrepare(StatementPreparerImpl.java:149)

This is a regression issue that was entered as part of this commit: https://github.com/quarkusio/quarkus/commit/8c76e39060f6b288eaaeeb28bc477b33a972a40f. In this commit, the @Transactional annotations were removed from the REST methods and added into the inner methods. The problem with the update implementation is that is calling two inner methods (get and update).

Expected behavior All REST methods should use only one connection.

Actual behavior PUT REST method needs at least two connections.

To Reproduce 1- git clone https://github.com/Sgitario/beefy-scenarios 2- cd beefy-scenarios/014-quarkus-panache-with-transactions-xa 3- git checkout reproducer_15369 4-mvn clean install (it needs to have built quarkus master locally)

This example is basically doing this:

  1. Create a resource
  2. Update the existing resource -> here it fails

Environment (please complete the following information):

  • Quarkus version or git rev: 999-SNAPSHOT (1.12.1.Final)

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
gytiscommented, Mar 9, 2021

Just wanted to point that out. I will nevertheless add the transaction.

1reaction
FroMagecommented, Mar 9, 2021

OK, right, single transaction is definitely a requirement, we can agree on that 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Generating JAX-RS resources with Panache - Quarkus
REST Data with Panache generates JAX-RS resources based on the interfaces available in your application. For each entity and repository that you want...
Read more >
Java Quarkus Panache (Hibernate) doesn't update entity ...
I think it's not updated because you are using persist with an existing entity. Because the entity is managed and exists, you can...
Read more >
Hibernate with Panache :: Quarkus Tutorial - GitHub Pages
For this, we'll develop a simple CRUD REST API that handles ... With Dev Services enabled, no JDBC URL needs to be provided...
Read more >
Simplified MongoDB with Panache - Quarkus
the list() method might be surprising at first. It takes fragments of PanacheQL queries (subset of JPQL) and contextualizes the rest.
Read more >
A Qute Way to Visualise Data with Panache - Antonio's Blog
How to display the data from the database in HTML using Qute templates. ... engine designed specifically to meet the Quarkus needs.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found