Gotchas

The following is a quick checklist of “gotchas” to help you with your implementation:

  • Primary keys must be immutable. In other words, it is not possible to change the value of a primary key for an entity once assigned.

  • Sometimes, Entity beans interact with non-data store resources such as a subscription to a JMS topic (covered on Day 9, “Java Message Service,” and Day 10, “Message-Driven Beans”). These resources should be acquired in setEntityContext() and released in ejbPassivate() and re-acquired in ejbActivate(). Resources should also be released in unsetEntityContext().

  • Finder methods can return a Collection, but they can't currently return a List, Set, or Map object.

  • If you have two bean references, note that the value of bean1.equals(bean2) ...

Get Sams Teach Yourself J2EE™ in 21 Days, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.