Apress Pro JPA 2 Mastering Java Persistence API 898

shareefhiasat's version from 2016-06-02 08:37

Section 1

Question Answer
When Singleton Bean introducedEJB 3.1
When no interface view introducedEJB 3.1 e.g when you define bean with @Stateless for example without need to interface
PostConstruct callback is required ?you can have at most one PostConstruct in a bean and @PreDestroy too
@Remote when used how the arguments are passed?The are passed by value. not reference
Every statefull session bean must have at least one method marked by ?@Remove
@PrePassivate used when?preparing the bean for serialization and there is @PostActivate
@Startup used for...?Eagerly force initialization when the application starts
Container Concurrency Managed Types are two what are they?Container managed and Bean managed concurrency
Whats the annotation to protect the concurrency?@Lock(LockType.Read) and Write
MDB message driven bean is ?is EJB component used for asynchronous messaging client calls it using JMS and these requests are queued

Section 2

Question Answer
resource reference annotations examples are?@EJB @Resource @PersistenceUnit @PersistenceContext
JNDI used for?traditional way for resolving dependency lookup for resources
Dependency Injection is ?The process of automatically looking up resource and setting it into the class . its called inversion of control
Dependency Injection vs JNDI which is better?of course dependency injection because it reduce the need for JNDI lookup code and good for testing
Give one Dependency Injection form Field Injection , Setter Injection , using @EJB AuditService audit; and its better thant @EJB(name="audit",beanInterface="AuditService.class") and use lookup
How to use @PersistenceUnit in @Stateless and @Statefull beans?Yes we can use it in both remember if you use it in @Stateless it will not create instance of it but rather will create managed proxy ,
What is the default transaction managment?for a bean the default is Container managed
What are the transaction attributes for container managed transactional behavior?MANDATORY,REQUIRED,REQUIRES_NEW,SUPPORTS,NOT_SUPPORTED,NEVER