-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: Transaction attribute on GenericEjb3DAO method
PostPosted: Mon Aug 07, 2006 5:57 am 
Newbie

Joined: Wed Feb 01, 2006 10:51 am
Posts: 3
Hello,

one short question regarding generic EJB3 DAO pattern.
Let's say on certain entity I want to have create method (makePersistent) to be run in the new transaction. This way outer transaction can handle creation exception. In such cases I would use:

@TransactionAttribute(value = TransactionAttributeType.REQUIRES_NEW)

As I need a method for above annotation, I override makePersistent in implementing session bean:

Code:
  @TransactionAttribute(value = TransactionAttributeType.REQUIRES_NEW)
  public User makePersistent(User entity) {
    return super.makePersistent(entity);
  }


this has no effect and the call is not executed in a new transaction.
If I define new method on the business interface (UserDAO):

public User makePersistent(User user);

the call is executed within a new transaction. Adding such method to DAO interface for particula entity doesn't make sence as there is "the same" one in the GenericDAO.

So the short question is: how to set transactional attributes on the methods defined in GenericDAO and implemented by GenericEjb3DAO, but only for some entities?

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 07, 2006 6:14 am 
Newbie

Joined: Wed Feb 01, 2006 10:51 am
Posts: 3
This does exactly what I wanted:
Code:
<ejb-jar>
   <assembly-descriptor>
      <container-transaction>
         <method>
            <ejb-name>UserDAO</ejb-name>
            <method-name>makePersistent</method-name>
         </method>
         <trans-attribute>RequiresNew</trans-attribute>
      </container-transaction>
   </assembly-descriptor>
</ejb-jar>


But I still wonder if possible to make it using annotations...


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 07, 2006 4:00 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Ask in some (not the Hibernate, better the JBoss) EJB 3.0 forum. AFAIK this kind of inheritance doesn't work (yet).


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 08, 2006 3:12 am 
Newbie

Joined: Wed Feb 01, 2006 10:51 am
Posts: 3
Thanks, I re-posted the question on EJB/JBoss forum:

http://www.jboss.com/index.html?module=bb&op=viewtopic&t=88236


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.