4 Replies Latest reply on Mar 8, 2013 10:21 AM by Radouane El Marjani

    Mixing database and Repository: what is the best solution?

    Radouane El Marjani Newbie

      Hi,

       

      I have a general question:

       

      - I want to store my model (for example: patient, surgeon, procedure... as tables) in database and the patient  documents/media in modeshape repository, so that I can do my queries between DB and repository.

      - I know, I can use modeshape for all structure, but we have already all data in database and now we want to persit documents of these patients in repository and keep our data model in database.

       

      My idea to persist patient, surgeon and procedure in DB and after that I  create nodes that are in relations with names: " database ids"  of these created database data (node: patient_id, procedure_id, surgeon_id) and I have to persist then  documents and media under these nodes. If I want to have all documents of a patient, I get the id first from database and I do then my query on repository based on this id to get all documents of this patient.


      Is this a good way to do it or you see another way. is federation connector a solution for this?

       

      it's will be great if I get your responses about this?

       

      Thanks and regards,

       

      Radouane

       

        • 1. Re: Mixing database and Repository: what is the best solution?
          Randall Hauch Master

          Storing data in multiple data stores will always be a challenge, but sometimes it is necessary.

           

           

          - I want to store my model (for example: patient, surgeon, procedure... as tables) in database and the patient  documents/media in modeshape repository, so that I can do my queries between DB and repository.

          - I know, I can use modeshape for all structure, but we have already all data in database and now we want to persit documents of these patients in repository and keep our data model in database.

           

          My idea to persist patient, surgeon and procedure in DB and after that I  create nodes that are in relations with names: " database ids"  of these created database data (node: patient_id, procedure_id, surgeon_id) and I have to persist then  documents and media under these nodes. If I want to have all documents of a patient, I get the id first from database and I do then my query on repository based on this id to get all documents of this patient.

           

          This sounds like it would work. You might need to have some hierarchical organization above the nodes representing the database entities, just so that you don't have all your database entities (of a particular kind) all under one parent. (I'm assuming you'll have more than 100Ks of entities; the overhead of reading a parent node with 10K child nodes is relatively small, but it does get bigger with larger numbers of nodes. This is a hiearchical database, after all.) There are various approachs depending upon what kind of IDs you are using, including creating intermediate nodes that use a portion of your ids to partition a set of entities into different areas of the hierarchy.

           

           

          is federation connector a solution for this?

          At the moment, we have no connector to the data in a relational database of an arbitrary schema. So I don't think federation is a practical solution at this time.

          • 2. Re: Mixing database and Repository: what is the best solution?
            Radouane El Marjani Newbie

            Thanks for your answer.

             

            I read some old discussions in forum, where they use databse connector "org.modeshape.connector.store.jpa.JpaSource" ,  but I see under module of modeshape in connector packet just "git" and no others connectors.

            Is that the connector that  I need, or this connector exist not more...

             

            Is not a solution to do something like this in standalone.xml of JBoss to get a federation to my database and then have database as nodes and I can persist my documents under these nodes ...

             

                  <source name="postgresqlSource" classname="org.modeshape.connector.store.jpa.JpaSource" dialect="org.hibernate.dialect.PostgreSQLDialect" 
                       data-source-jndi-name="java:jboss/datasources/MydatabaseDS" default-workspace="orc">
                          <projection>orc:/db => /</projection>
                  </source>
            
            • 3. Re: Mixing database and Repository: what is the best solution?
              Randall Hauch Master

              I read some old discussions in forum, where they use databse connector "org.modeshape.connector.store.jpa.JpaSource" ,  but I see under module of modeshape in connector packet just "git" and no others connectors.

              Is that the connector that  I need, or this connector exist not more...

              That old 2.x connector used a specific DBMS schema to store ModeShape content in the database via JPA, and did NOT work with arbitrary, user-defined JPA entities or database tables. So that option would not have worked in this scenario. Besides, it's been removed from ModeShape 3.x, which has a different architecture.

               

               

              Is not a solution to do something like this in standalone.xml of JBoss to get a federation to my database and then have database as nodes and I can persist my documents under these nodes ...

               

                    <source name="postgresqlSource" classname="org.modeshape.connector.store.jpa.JpaSource" dialect="org.hibernate.dialect.PostgreSQLDialect" 
                         data-source-jndi-name="java:jboss/datasources/MydatabaseDS" default-workspace="orc">
                            <projection>orc:/db => /</projection>
                    </source>

              No, that would not work. See my answer above.

               

              Your application can indeed store some data in a DBMS and other data/content in a ModeShape repository. As you suggested, your application has to have logic to deal with both.

              • 4. Re: Mixing database and Repository: what is the best solution?
                Radouane El Marjani Newbie

                Thanks fou your time and for your answer. I will look for my own logic for this problem.

                 

                Regards,

                 

                 

                Radouane