deltaspike-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Lucian BRANCOVEAN <>
Subject TransactionRequiredException when a transaction should exist
Date Mon, 04 May 2020 20:24:04 GMT

I am using Deltaspike 1.9.3 in Wildfly 14.

I have a CDI bean with a method that is supposed to insert or update an entity, like this:

public class StuffService {

    private StuffRepository repository; // StuffRepository extends EntityRepository<Stuff,


    public void save(Stuff stuff) throws Exception {

        if (stuff.getCode() == null) {

        } else {

            Stuff entity = getByCode(stuff.getCode()); // code is @Id

This works, but looking at the javadoc, I understand that it already
does what I want, decide if to update or insert a new record based on the presence/absence
of a primary key value.

However, if I call on an existing entity (so I remove the if and always
go in the first branch), I get an exception:

javax.persistence.TransactionRequiredException: WFLYJPA0060: Transaction is required to perform
this operation (either use a transaction or extended persistence context)

What happens here? How come a transaction does not exist unless I create a new object and
transfer the data into it?

What I guess might be relevant is that the Stuff entity comes from a ViewScoped bean, from
a previous request.

Note, I am using container-managed transactions, and javax.transaction.Transactional. Should
I use org.apache.deltaspike.jpa.api.transaction.Transactional? What is the difference?

Thanks in advance,


  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message