tree: cec7aa276b6fcc9f112076eaf0e2463fb45fab42 [path history] [tgz]
  1. src/
  2. pom.xml
  3. README.md
examples/dynamic-dao-implementation/README.md

Dynamic DAO Implementation

Note: this feature is not standard

OpenEBJ support EJB annotations on interfaces (in particular @Stateless and @Singleton).

The interface has to be annotated with @PersistenceContext to define which EntityManager to use.

Methods should respect these conventions:

  • void save(Foo foo): persist foo
  • Foo update(Foo foo): merge foo
  • void delete(Foo foo): remove foo, if foo is detached it tries to attach it
  • Collection|Foo namedQuery(String name[, Map<String, ?> params, int first, int max]): run the named query called name, params contains bindings, first and max are used for magination. Last three parameters are optionnals
  • Collection|Foo nativeQuery(String name[, Map<String, ?> params, int first, int max]): run the native query called name, params contains bindings, first and max are used for magination. Last three parameters are optionnals
  • Collection|Foo query(String value [, Map<String, ?> params, int first, int max]): run the query put as first parameter, params contains bindings, first and max are used for magination. Last three parameters are optionnals
  • Collection findAll([int first, int max]): find all Foo, parameters are used for pagination
  • Collection findByBar1AndBar2AndBar3(<bar 1 type> bar1, <bar 2 type> bar2, bar3 [, int first, int max]): find all Foo with specified field values for bar1, bar2, bar3.

Dynamic finder can have as much as you want field constraints. For String like is used and for other type equals is used. See UserDao for an example and DynamicUserDaoTest for an usage example.

Download

Download as zip

Files

APIs

${apis}

Java files

${javas}

Resource files

${resources}