1 Reply Latest reply on Apr 8, 2005 4:40 AM by tpaterson

    Entity Beans not portable between diffirent DB

    tbech

      Hi all,
      I had to port application to PostgreSQL and I found it rather clumsy.
      One of the key of EJB/or other good persistance is independence of underlying DB.
      Even if I use EJBQL, portable selects, etc. JBoss-Entity-Beans depend on the DB type.
      1. jbosscmp-jdbc.xml
      <jbosscmp-jdbc>

      <datasource-mapping>PostgreSQL</datasource-mapping>

      2. jbosscmp-jdbc.xml - auto generated keys
      <entity-command name="postgresql-fetch-seq">
      xx
      </entity-command>

      3. No abstraction of CLOB-Oralce/TEXT-PostgreSQL.

      All those files must be change in order to port to other DB vendor. In my opinion it is major flaw in design of Entity/persistance layer. This should never be set in application descriptors. Simply it should depend on the type of the driver. If driver is Oracle - use datasource-mapping for Oracle, the same for the sequence. Even if you don't want (or impossible) to do it by detecting the driver, simply specify it in the jca db xml configuration file.

      Hope, there will be refactoring of JBoss to simply the developers work.

      But, what now?
      I use xdoclet to generate all stubs and descriptors. Two DBs means to me changes in the .java files. How to deal with:
      * @jboss.entity-command name="postgresql-fetch-seq/ or oracle-sql here"
      * @jboss.entity-command-attribute name="sequence" value="xxx_sequence"

      Should I back 20 years and make some preprocessing (like C #define)? Horrible. Should I do some postprocessing on descriptors? (a little bit better).
      Does someone has good experience with such tiny but ugly configuration?
      Thanks,
      tbech

        • 1. Re: Entity Beans not portable between diffirent DB

          Not a 100% solution -- but I'm pretty sure you can use some kind of variable names in your xdoclet tags, and then setup your ANT build file and xdoclet task to replace those as required, e.g.

          * @jboss.entity-command name="${entity-command-name}"
          * @jboss.entity-command-attribute name="sequence" value="${entity-command-att-sequence}"

          so if you updated all of your .java files like so -- you would only have to update your build script if you needed to change again in future !


          more details here : http://xdoclet.sourceforge.net/xdoclet/using.html