Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

@Transactional within PanacheEntity?

Tags:

quarkus

Is this allowed in quarkus?

@Entity
public class User extends PanacheEntity  {

    // is @Transactional annotation allowed within an Entity
    @Transactional 
    public static final updateName(String name){
       ...
    }

}

Does quarkus allow the annotation @Transactional to be set within a static method (which is normally not bound to a context (CDI-Bean))..depending on PanacheEntity.

like image 418
nimo23 Avatar asked Oct 24 '25 04:10

nimo23


1 Answers

No, that is not allowed.

You will get javax.persistence.TransactionRequiredException: Transaction is not active, consider adding @Transactional to your method to automatically activate one.

You have to add the annotation @Transactional to the wrapping method of your resource.

The built-in method persist() does not have the annotation set, so even the quarkus default method wont work without a wrapped @Transactional.

like image 159
alexander Avatar answered Oct 27 '25 01:10

alexander



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!