1 2 3 Previous Next 33 Replies Latest reply on Jan 15, 2008 8:24 AM by bershath27 Go to original post
      • 15. Re: JBM 2.0 JDBCPersistenceManager - volunteers?
        ataylor

        I think what Tim's trying to say is that since we dont have a domain model that maps to our database we cant just annotate the message and messageref objects to be able to save them direct via a hibernate session. i.e. look at the messageref object and compare it with the database table, it has other fields such as channell_id and transaction_id. For this to work using Hibernate normally you'd have to add a relationship between messageref object and the destination object and the transaction object which wouldn't make sense.

        It is possible to access the dialect direct, but its not well documented and i'm not sure if its usable. maybe we need a rethink, how about writing some ansii standard sql and just using JDBC, our schema isnt very complex and we should be able to do that?

        • 16. Re: JBM 2.0 JDBCPersistenceManager - volunteers?
          timfox

           

          "ataylor" wrote:
          I think what Tim's trying to say is that since we dont have a domain model that maps to our database we cant just annotate the message and messageref objects to be able to save them direct via a hibernate session. i.e. look at the messageref object and compare it with the database table, it has other fields such as channell_id and transaction_id.


          Yes that's pretty much it


          how about writing some ansii standard sql and just using JDBC, our schema isnt very complex and we should be able to do that?


          Not sure that's going to work or we'd have done it already - there is significant difference between the databases for the types used to store blobs for instance amongst other things.

          Time to reach for the Hibernate book soon..........

          • 17. Re: JBM 2.0 JDBCPersistenceManager - volunteers?
            timfox

            Hi Tyronne-

            Any more progress on this?

            • 18. Re: JBM 2.0 JDBCPersistenceManager - volunteers?
              bershath27

               

              "timfox" wrote:
              Hi Tyronne-

              Any more progress on this?

              yes. i have already started creating a working model, i can complete this task by 10th.

              to tell you the truth, i have already done this with a test case and trying to locate the project. since i have backed up my HDD during the re-installation of my OS. ;)

              i'm using ORM using POJO's instead of Map of maps due to the following reasons :

              - maintenance and debugging is awful with map of maps
              - poor refactoring
              - you use String everywhere
              - detyped properties
              - the fact, you can't have recursive structures since a Map uses equals/hashcode to define uniquness so guess what happens if you have circular references between maps
              - map of maps is very rarely usable (mostly only when you are dealing
              with prototypes or meta-meta programming it would be usefull..but mainly
              because one is too lazy)

              these are the valid reasons i have for you, to move along with ORM. some of them were suggested by the HB team members. please let me know if you have any alternative to this.

              thanks
              Tyronne

              • 19. Re: JBM 2.0 JDBCPersistenceManager - volunteers?
                timfox

                 

                "bershath27" wrote:
                please let me know if you have any alternative to this.


                The other possibility, as Aaron and others have pointed out, is to just use Hibernate dialects to abstract out the particulars of the database, but we then just execute it directly using JDBC, i.e. no ORM.



                • 20. Re: JBM 2.0 JDBCPersistenceManager - volunteers?
                  anthonyhib

                  Hi Guys,
                  I've read the topic twice but excuse me if I've misunderstood something.
                  Here are my comments:
                  1- Using Hibernate/JPA just because Schema Export is useful isn't a sufficient argument. Schema Export is a development tool. Generated Schemas need to be reviewed/tuned by a DBA, so you cannot rely 110% on it in production
                  2- Using Hibernate/JPA to generate the Schema and then use pure JDBC seems weird.
                  3- I don't feel detyped/dynamic model will be more efficient than a pure oo domain model

                  If you requirements are:
                  - DML/DDL depending the target DB
                  - most efficient module in terms of performance, avoid the little overhead of ORM
                  Then I'd suggest you to go and use pure JDBC and write a set of fully tested DDL/DML for each database and insert a config parameter.

                  Anyway, if your model isn't complex, I'd suggest you to code 3 prototypes
                  - OO domain model + ORM
                  - OO domain model + JDBC
                  - map of map with jdbc
                  and test it under heavy load

                  I'm pretty sure the overhead of ORM will be very very small.

                  I'd be happy to help you to tune your ORM based prototypes.

                  Anthony Patricio
                  Hibernate/JPA support engineer.

                  • 21. Re: JBM 2.0 JDBCPersistenceManager - volunteers?
                    timfox

                    Hi Anthony-

                    The primary objective of this exercise is to avoid having to maintain our own set of DDL and DML for each database, this is what we already do in JBM 1.x and is a big PITA and maintenance hassle.

                    The idea was to leverage Hibernate to abstract out the differences between the different databases DDL, DML.

                    One way to do that, would be to use Hibernate as ORM.

                    Currently we just use a few simple hand tuned SQL statements, note that we *do not* have an existing domain model that maps to the tables.

                    If we were to use Hibernate as ORM we would have to create a domain model. Also it's my understanding we would have caching (which we don't want). All which seems a lot of unnecessary overhead.

                    I know very little about Hibernate and what it is capable of, but I was under the impression it provided an API that would let us map "abstract" DDL/DML (i.e. using some abstract database indepdendent query language), into *real* DDL/DML that could be used against a specific database.

                    If this is the case, it would seem this is the simplest way to fulfil our requirements - this would avoid having to create/maintain an extra domain layer that we really don't need.

                    However, maybe I am mistaken / misinformed and such an API does not exist, in which case I imagine we need to go down the ORM route. If this is the case I would like to know if HIbernate can be configured to not cache - basically just act as a raw "translator".

                    If you could advise me on my assumptions/misundertstandings that would be great. :)

                    • 22. Re: JBM 2.0 JDBCPersistenceManager - volunteers?

                       

                      Anthony

                      1- Using Hibernate/JPA just because Schema Export is useful isn't a sufficient argument. Schema Export is a development tool. Generated Schemas need to be reviewed/tuned by a DBA, so you cannot rely 110% on it in production


                      Correct you most creatainly need way to generate scripts that can be reviewed by DBA for going into production. With previous versions of JBossMQ and JBM I would run the app server configured with a DB user with create premissions in a dev/test environment have if create the tables etc the use a tools to extract the DDL so it can be used to create the prod environment. This is always a pain. How I saw this work was that I could simply run a script that would generate the correct DDL from some hiberante config. Now whether we then just use pure JDBC or Hibernate at run time is a seperate issue.

                      JBPM does this quite nicely in that the have a seperate DB project which you to create DDL for both new systems and when upgrading to new versions (alter scripts).



                      Tim

                      However, maybe I am mistaken / misinformed and such an API does not exist, in which case I imagine we need to go down the ORM route. If this is the case I would like to know if HIbernate can be configured to not cache - basically just act as a raw "translator".


                      Hibernate has the concept of a stateless session which is means no session level caching. I spoke to Gavin sometime ago about using Hibernate for persitance for the JBM project and he said it really was a good fit but if we did go down this path then use the stateless session.

                      The persisntance requirements for messaging are pretty simple and I think it´s possible to tune a pure JDBC solution and that ORM is overkill for runtime. I think it would be a good idea to try a couple of prototypes I happy to work on one or two of them.






                      • 23. Re: JBM 2.0 JDBCPersistenceManager - volunteers?
                        anthonyhib

                        well you hit 2 distinct things:
                        1- DDL, mainly used by Schema Export --> see my previous comment. SchemaExport uses hibernate metadatas to generate a schema creation script. (FYI metadatas is the place where you say my class Person is mapped to the PERSON table or, in your case, the PERSON table is mapped to the entity name "Person" if you don't have a real class)
                        2- DML. With Hibernate, you use HQL (or JPA QL), it's OO based on class and property names (associations, collections, basic properties).
                        2-a, if you use dynamic models, you'll have to define aliases (entity-name) instead of using class and property names). Then, in your java code, when querying, you'll use theses aliases. The HQL query will be translated in SQL
                        2-b if you don't like the generated SQL, if you want to tune it, you'll have to use the SQL query feature which is very close to pure JDBC...

                        3- about caching, you can disable all the caches.

                        I must admit that this is a very specific usage of hibernate, I'm pinging the core Hibernate guys to get their feelings.

                        • 24. Re: JBM 2.0 JDBCPersistenceManager - volunteers?
                          anthonyhib

                          Christian advices not to use the stateless session (Hibernate session with first level cache disabled).
                          I really think we should bench the 2 or 3 options we have.
                          How many tables are you using? How many joins in the queries? Will you have concurrent access?...

                          • 25. Re: JBM 2.0 JDBCPersistenceManager - volunteers?
                            cbredesen

                            I agree with Anthony's assessment that using Hibernate as nothing more than a portability tool is the wrong approach. It will certainly work, and likely work well, but we have to consider the support issues going forward when a JMS application suddenly becomes a JMS + Hibernate one.

                            Hibernate is a good abstraction, but it can be a bit leaky when it becomes a fundamental layer of the appserver. We see this today with jBPM. While you'd win in terms of ease of portability across RDBMSs, you'd potentially lose with extra complexity for JBM.

                            I'd have to look more at how JBM does persistence today to see what opportunities there are for improvement besides using Hibernate.

                            • 26. Re: JBM 2.0 JDBCPersistenceManager - volunteers?
                              cbredesen

                               

                              Hibernate is a good abstraction, but it can be a bit leaky


                              By "leaky" I mean "leaky abstraction", not "memory leak". Although we've had our share of the latter too :)

                              • 27. Re: JBM 2.0 JDBCPersistenceManager - volunteers?
                                timfox

                                Just to clarify - we're not considering using HIbernate for our primary persistence mechanism.

                                We're considering using Hibernate to implement our JDBC PersistenceManager.

                                Primary form of persistence is a fast file based append only journalling approach.

                                The JDBCPersistenceManager is mainly so JBM can work out of the box with JBAS and the default database, and for those customers that really want JDBC but do so understanding performance will be much poorer.

                                • 28. Re: JBM 2.0 JDBCPersistenceManager - volunteers?
                                  jay.howell

                                  Tim, correct me if I'm wrong....
                                  The db persistence interface is only there so we can work out of the box. The "real" persistence that we are recommending to customers will be the file based persistence utilizing Oracle's Berkeley DB. That is going to be the persistence that we will recommend to customers, if they call and say that the db persistence runs slow.

                                  Because of licensing constraints, we can't ship Berkeley DB, so we ship with a db persister that utilizes hypersonic. Since we are shipping with a db persister, the thinking is that we should ship with something that plugs into many DBs.

                                  Since we have to work out of the box, with hypersonic, then we should just make a jdbc persister that can use all databases. So then we would have to maintain scripts, so we use an abstraction that will keep us from maintaining scripts. I agree that using hibernate, the performance may be slower. It usually is when you introduce an abstraction. But what we get for the possible performance hit is that the the messaging team doesn't have to write and maintain a script for each database.

                                  The question that I have is, since the db persistence manager is not the manager that will will eventually recommend to our customers, should we really need to worry about any other database, other than the one we ship with? Why would anyone use Oracle, or Mysql for JMS persistence, when it will be slower than the Berkeley DB file persister.

                                  I guess what I'm saying is that I think the DB persistence manager is not really that important since the recommended persistence manager will be Berkeley DB. So why are we putting work into making a cross db persistence mechanism in the first place. We could keep the current code base(with only one script) and just support the internal db that we ship with, hypersonic(yuck). The messaging team wouldn't have to do any work and one script would be easy to keep up with. When users say, Hypersonic is bad, we tell them to use Berkeley DB. It seems much simpler to have two choices and much easier to support. I'd definitely vote to throw out cross db persistence in JBM.

                                  Jay:)

                                  • 29. Re: JBM 2.0 JDBCPersistenceManager - volunteers?
                                    maxandersen

                                    my 2 cent:

                                    Afaik from the talks I had with Tim and others from messaging you guys basically have 1 or 2 tables you are doing data inserts into - nothing fancy at all and you don't really have any "state" to carry around except single messages.

                                    For that StatelessSession is the right thing to use if you want to use hibernate.