Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Is the statement about EJB 3.x right?

 
Yingjie Liu
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 754
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I believe that EJB will ignore this annotation on an entity. @TransactionManagement(TransactionManagementType.BEAN)
 
Ivan Krizsan
Ranch Hand
Posts: 2198
1
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
Yingjie Liu
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2198
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Got it, Thank you very much!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic