Uploaded image for project: 'Spring Roo'
  1. Spring Roo
  2. ROO-3082

Map two subclasses of the same abstract superclass into two persistence units

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Complete
    • Affects Version/s: 1.2.0.RELEASE
    • Fix Version/s: 1.2.2.RELEASE
    • Component/s: None
    • Labels:
      None

      Description

      I have an abstract superclass who defines the properties. Two concrete subclasses I want to map into two databases.

      The definition of my base class:

      Message.java
      @RooJavaBean
      @RooJpaActiveRecord(mappedSuperclass = true)
      public abstract class Message {
          private String basename;
          private String language;
          private String country;
          private String variant;
          private String key;
          private String message;
      }
      

      results in:

      Message_Roo_Jpa_ActiveRecord.aj
      @RooJavaBean
      @RooJpaActiveRecord(mappedSuperclass = true)
      privileged aspect Message_Roo_Jpa_ActiveRecord {
          
          @PersistenceContext
          transient EntityManager Message.entityManager;
      ...
      

      My default implementation who points to the persistenceUnit=pu1 is defined as:

      DefaultMessage.java
      @RooJavaBean
      @RooToString
      @RooJpaActiveRecord(table = "message", persistenceUnit = "pu1")
      public class DefaultMessage extends Message {
      ...
      

      My specialized implementation who points to persistenceUnit=pu2 is defined as:

      SpecializedMessage.java
      @RooJavaBean
      @RooToString
      @RooJpaActiveRecord(table = "message", persistenceUnit = "pu2"
      public class SpecializedMessage extends Message {
      ...
      

      The only EntityManager to inject is in the Message_Roo_Jpa_ActiveRecord.aj without any persistenceUnit name defined. I need in any concrete implementation an EntityManager pointing to the right persistence unit.

        Attachments

          Activity

            People

            Assignee:
            stewarta Alan Stewart
            Reporter:
            akessler@rolotec.ch Andy Kessler
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: