0 Replies Latest reply on Nov 22, 2008 3:54 AM by Dmitry Shultz

    Advice on reusing Entities code

    Dmitry Shultz Newbie

      Hello,


      From what I know it seems no way, but there is still a big hope that I'm wrong.


      Let's say i have some well debugged code of Entity that i want to reuse by extending it.
      The code can be like this:


      @Entity
      @Inheritance(strategy = InheritanceType.SINGLE_TABLE)
      @Table(name = "files", schema = "app1")
      @DiscriminatorColumn(name = "type", discriminatorType = DiscriminatorType.STRING, length = 1)
      abstract public class FileHandler implements Serializable {
          @Id
          @GeneratedValue
          private int id;
          ...
      }



      @Entity
      @DiscriminatorValue(value = "I")
      public class ImageFile extends FileHandler {
          ...
      }



      The base class FileHandler entity is a part of some home brewed jar library that can be used by any project. The only problem with it is that all projects (applications) will persist their FileHandler objects at the same table if they using the same database.
      I can create different connection pools for each application pointing to the different databases, but what i want is to have one single connection pool for some set of projects.


      Is it possible to configure the @Table anotation dynamically, so all projects will use different tables?