[JVM] Spring, JPA, JTA

167 views
Skip to first unread message

Jeffrey Cameron

unread,
Mar 25, 2013, 9:18:59 PM3/25/13
to cu...@googlegroups.com
Hey all,

There is a cucumber-glue scope provided in cucumber-spring that can be used to scope objects to a scenario.  Should I be using this scope for any of my JPA related objects?  Right now, we don't give any special scope to our data source or entity manager factory beans but what we are noticing is that when one scenario fails it has an effect on the other scenarios that are running.  Many times we might see a "Session is closed" exception of some sort and all further scenarios fail.  My thinking was that if we scoped the EntityManagerFactory (and/or the TransactionManager) to the scenario that we might avoid this problem.

Note: we are not using the @txn tag provided by cucumber-spring to manage transactions.

Thoughts?

Thanks in advance

Jeffrey Cameron

unread,
Mar 29, 2013, 4:02:28 PM3/29/13
to cu...@googlegroups.com
I guess no one else has run into this issue ...

In case someone else does, I managed to get it working with latest versions of Spring Data.  I pushed up an example repository to here: https://github.com/x97mdr/spring-data-lazy-loading.git

It uses the @txn tag to use transactions to allow entities to be lazy loaded in step definitions.

Thanks


--
-- Rules --
 
1) Please prefix the subject with [Ruby], [JVM] or [JS].
2) Please use interleaved answers http://en.wikipedia.org/wiki/Posting_style#Interleaved_style
3) If you have a question, don't reply to an existing message. Start a new topic instead.
 
You received this message because you are subscribed to the Google Groups Cukes group. To post to this group, send email to cu...@googlegroups.com. To unsubscribe from this group, send email to cukes+un...@googlegroups.com. For more options, visit this group at https://groups.google.com/d/forum/cukes?hl=en
---
You received this message because you are subscribed to a topic in the Google Groups "Cukes" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/cukes/pyotNLhx_3o/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to cukes+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

mathias kluba

unread,
Jul 21, 2013, 2:32:50 AM7/21/13
to cu...@googlegroups.com
Le vendredi 29 mars 2013 21:02:28 UTC+1, Jeffrey Cameron a écrit :
I guess no one else has run into this issue ...


Hi,
I have exactly the same problem!

 
In case someone else does, I managed to get it working with latest versions of Spring Data.  I pushed up an example repository to here: https://github.com/x97mdr/spring-data-lazy-loading.git

It uses the @txn tag to use transactions to allow entities to be lazy loaded in step definitions.

Thanks


Thanks, but in my case, it doesn't work.
In fact, the Lazy Loading is working.
But I don't know why, I have a strange behavior with JPA.
I have several mapping for the same table, when I save the object A, I can query A and retrieve A.myCollection.
But then, when I query B, I can retrieve it but B.myCollection is empty.

Anyway, I prefer to commit on each steps, so I can verify the temporary Database in case of test failure.
(And I purge it before each scenarios).

But I didn't find any way to repeat an action before/after any steps.
Am I missing something?

The @Transactional on steps is not working, because cucumber-spring is creating the Test class with a constructor, so Spring is not responsible of creating the Test class and can't do AOP.

Is it a feature request that I can create in Github ?
 
Reply all
Reply to author
Forward
0 new messages