aspose file tools*
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Is the statement about EJB 3.x right? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Is the statement about EJB 3.x right?" Watch "Is the statement about EJB 3.x right?" New topic
Author

Is the statement about EJB 3.x right?

Yingjie Liu
Greenhorn

Joined: Nov 24, 2011
Posts: 10
Dear All,

a transaction management type can not be specified for ejb 3.x entiites?

but I think it can, I make a test on glass fish, my test structure

servlet--> statefull bean--> entity can be successfully run. the city data can be inserted in to the database.




[Edit - added code tags = MB]
Hebert Coelho
Ranch Hand

Joined: Jul 14, 2010
Posts: 754

I believe that EJB will ignore this annotation on an entity. @TransactionManagement(TransactionManagementType.BEAN)


[uaiHebert.com] [Full WebApplication JSF EJB JPA JAAS with source code to download] One Table Per SubClass [Web/JSF]
Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
Hi!
EJB 3.x entities are, as far as I understand, classes annotated with JPA annotations.
In a Java EE environment, entities are usually manipulated by EJBs or other components, for which transaction management is specified.
Note that because you have managed to create an example program that runs on GlassFish does not mean anything - there are cases when GlassFish allows certain behaviour that does not adhere to EJB 3.1 specifications.
Reference: Section 13.3.6 EJB 3.1 specification.
Best wishes!


My free books and tutorials: http://www.slideshare.net/krizsan
Yingjie Liu
Greenhorn

Joined: Nov 24, 2011
Posts: 10
Hi,

Thanks for your reply, I checked the specification and there is another statement on the specification I do not understand

" The transaction management type of a bean is determined by the Bean Provider. The application assembler
is not permitted to use the deployment descriptor to override a bean’s transaction management type regardless of whether it has
been explicitly specified or defaulted by the Bean Provider. "

Does that mean application assembler can not use the 'transaction-type' to perform the overriding?


Thanks,
Yingjie



Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
Hi!
Yingjie Liu wrote:
Does that mean application assembler can not use the 'transaction-type' to perform the overriding?

Exactly.
If you think about it, changing the transaction type from BEAN to CONTAINER may render an EJB useless - any calls related to the object implementing UserTransaction would suddenly fail with system exceptions.
The transaction type is closely coupled to the code of the EJB class.
Best wishes!
Yingjie Liu
Greenhorn

Joined: Nov 24, 2011
Posts: 10
Got it, Thank you very much!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Is the statement about EJB 3.x right?