Contents ix Automating Environment Administration with Ant.....19 What Is a J2EE Application Environment?.................149 What Does It Mean to Administer a J2EE Application Environment? .151 Using Ant .152 Unit Testing with JUnit .168 Summary .177 Chapter 8 Alternatives to Entity Beans .179 Entity Beans Features........ .179 Entity Beans and Cognitive Dissonance.....................180 In Defense of Entity Beans...... ..182 Alternatives to Entity Beans .183 Use Straight JDBC/Stored Procedures 183 Use a Third Party O/R Mapping Product.................184 Build a Custom Persistence Framework...................184 Use Java Data Objects 184 An EJB Developer's Introduction to Java Data Objects .......185 Class Requirements and Dependencies............. .185 Build and Deployment Processes 187 Inheritance............ .188 Client APIs............... Dynamic versus Static Discovery Mechanisms 189 An EJB Developer's Guide to Using JDO .189 Preparing Your EJB Environment .189 Configuring Session Beans 190 Executing Use Cases and Transaction Management .191 Container-Managed Transactions .191 Bean-Managed Transactions .192 Caching/Lazy Loading and Reference Navigation .193 Finding Java Data Objects .194 Inter-Tier Data Transfer................................196 Summary ..197 Chapter 9 EJB Design Strategies,Idioms,and Tips ..................199 Don't Use the Composite Entity Bean Pattern ..... ..199 Use a Field-Naming Convention to Allow for Validation in EJB 2.0 CMP Entity Beans. .200 Don't Get and Set Value/Data Transfer Objects on Entity Beans.............. .201 Automating Environment Administration with Ant . . . . . . . . . . .149 What Is a J2EE Application Environment? . . . . . . . . . . . . . . . . .149 What Does It Mean to Administer a J2EE Application Environment? . . . . . . . . . . . . . . . . . . . . . . . .151 Using Ant . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .152 Unit Testing with JUnit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .168 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .177 Chapter 8 Alternatives to Entity Beans . . . . . . . . . . . . . . . . . . . . . . . . . . .179 Entity Beans Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .179 Entity Beans and Cognitive Dissonance . . . . . . . . . . . . . . . . . . . . .180 In Defense of Entity Beans . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .182 Alternatives to Entity Beans . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .183 Use Straight JDBC/Stored Procedures . . . . . . . . . . . . . . . . . . . .183 Use a Third Party O/R Mapping Product . . . . . . . . . . . . . . . . .184 Build a Custom Persistence Framework . . . . . . . . . . . . . . . . . . .184 Use Java Data Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .184 An EJB Developer’s Introduction to Java Data Objects . . . . . . . .185 Class Requirements and Dependencies . . . . . . . . . . . . . . . . . . .185 Build and Deployment Processes . . . . . . . . . . . . . . . . . . . . . . . .187 Inheritance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .188 Client APIs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .188 Dynamic versus Static Discovery Mechanisms . . . . . . . . . . . . .189 An EJB Developer’s Guide to Using JDO . . . . . . . . . . . . . . . . . . . .189 Preparing Your EJB Environment . . . . . . . . . . . . . . . . . . . . . . . .189 Configuring Session Beans . . . . . . . . . . . . . . . . . . . . . . . . . . . . .190 Executing Use Cases and Transaction Management . . . . . . . .191 Container-Managed Transactions . . . . . . . . . . . . . . . . . . . . . . . .191 Bean-Managed Transactions . . . . . . . . . . . . . . . . . . . . . . . . . . . . .192 Caching/Lazy Loading and Reference Navigation . . . . . . . . .193 Finding Java Data Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .194 Inter-Tier Data Transfer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .196 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .197 Chapter 9 EJB Design Strategies, Idioms, and Tips . . . . . . . . . . . . . . . . . .199 Don’t Use the Composite Entity Bean Pattern . . . . . . . . . . . . . . . .199 Use a Field-Naming Convention to Allow for Validation in EJB 2.0 CMP Entity Beans . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .200 Don’t Get and Set Value/Data Transfer Objects on Entity Beans . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .201 Contents ix