And how is the entity manager being created?

LieGrue,
Strub

> Am 14.12.2015 um 04:25 schrieb John D. Ament <[email protected]>:
> 
> Paul,
> 
> Could you show us what your test looks like, including how it injects the
> bean that is used here.
> 
> John
> 
> On Sun, Dec 13, 2015 at 10:09 PM Paul Wills <[email protected]>
> wrote:
> 
>> 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 <[email protected]> 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
>> 

Reply via email to