Gotchas

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

  • If the primary key is composite, a custom primary key class must be defined. The fields of this class must be public and must correspond in name and type to cmp-fields of the bean class.

  • cmp-field and cmr-field fields must begin with a lowercase letter, (so that it can be capitalized in the corresponding getter and setter method names).

  • If a collection is returned from a cmr-field's getter method, it must not be modified other than through Iterator.remove() (see EJB specification, section 10.3.6.1).

  • Collections returned by getter methods cannot be used outside of the transaction context in which they were materialized.

  • If a bean has no relationships, the Collection returned by the cmr-field's getter method will be empty, it will not be null. Conversely, if calling a cmr-field's setter method, null cannot be used; instead an empty collection (such as Collections.EMPTY_LIST) must be passed in.

  • EJB QL strings are in single quotes!!!

  • EJB QL strings define placeholders as ?1, ?2, and so on (rather than the JDBC syntax of just ?). This allows the arguments of the corresponding finder or select method to be bound in more than once.

  • When comparing strings in EJB QL, the strings must be identical to be equal. (This is different from SQL where trailing whitespace is usually ignored.)

  • An EJB QL empty string is '' (0 characters). Some RDBMS treat this as a null string, so beware! (See EJB Specification, section 11.2.9.)

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.224.68.28