deltaspike-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul Wills <paul.wi...@engsol.com.au>
Subject Re: During @Transactional method EntityManager.flush() causes TransactionRequiredException
Date Mon, 14 Dec 2015 03:09:39 GMT
I can confirm the Transactional annotation is being imported as follows

*import* org.apache.deltaspike.jpa.api.transaction.Transactional;

Regards,

Paul


On 10 December 2015 at 15:06, Paul Wills <paul.wills@engsol.com.au> wrote:

> Whilst the following method is called in a test case, run with
> CdiTestRunner, the entityManager.flush() call causes a
> TransactionRequiredException.
>
> @Transactional
> public void saveAndFetchUser() {
>     // Given - a new user
>     final User randomUser = createRandomUser(false);
>
>    // When - saved
>     final User savedUser = userService.saveUser(randomUser);
>     // Then - user is saved as well as history and can be retrieved by id
> and username
>     assertThat(savedUser.getRoles(), hasSize(greaterThan(0)));
>
>     entityManager.flush();  // manually flush as UaiCriteriaQueries aren't
> flushed automatically
>     final Paged<UserHistory> pagedHistory =
> findUserHistoryMostRecentFirst(randomUser.getUsername());
>     assertThat(pagedHistory.getDerivedTotal(), equalTo(1));
>     assertThat(pagedHistory.getList(), hasSize(1));
>
>     ...
> }
>
> Is this a bug, or is there another way to flush the changes to the
> database?
>
> Environment:
> weld: 2.3.1.Final
> deltaspike: 1.5.1.Final
> deltaspike dependencies
>
> <dependency>
>
> <groupId>org.apache.deltaspike.modules</groupId>
>
> <artifactId>*deltaspike*-*jpa*-module-*api*</artifactId>
>
> <version>${deltaspike.version}</version>
>
> <scope>compile</scope>
>
> </dependency>
>
> <dependency>
>
> <groupId>org.apache.deltaspike.modules</groupId>
>
> <artifactId>*deltaspike*-*jpa*-module-*impl*</artifactId>
>
> <version>${deltaspike.version}</version>
>
> <scope>compile</scope>
>
> </dependency>
>
> <dependency>
>
> <groupId>org.apache.deltaspike.core</groupId>
>
> <artifactId>*deltaspike*-core-*api*</artifactId>
>
> *<version>${deltaspike.version}</version>*
>
> <scope>compile</scope>
>
> </dependency>
>
> <dependency>
>
> <groupId>org.apache.deltaspike.core</groupId>
>
> <artifactId>*deltaspike*-core-*impl*</artifactId>
>
> *<version>${deltaspike.version}</version>*
>
> <scope>compile</scope>
>
> </dependency>
>
> <dependency>
>
> <groupId>org.apache.deltaspike.cdictrl</groupId>
>
> <artifactId>*deltaspike*-*cdictrl*-weld</artifactId>
>
> <version>${deltaspike.version}</version>
>
> <scope>test</scope>
>
> </dependency>
>
> <dependency>
>
> <groupId>org.jboss.weld.se</groupId>
>
> <artifactId>weld-*se*-core</artifactId>
>
> *<version>${weld.version}</version>*
>
> <scope>test</scope>
>
> </dependency>
>
> Regards,
> Paul Wills
>

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