Tapestry
  1. Tapestry
  2. TAPESTRY-1372

Allow contributions to the Hibernate Configuration

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 5.0.3
    • Fix Version/s: 5.0.6
    • Component/s: tapestry-hibernate
    • Labels:
      None

      Description

      There is no way to configure the Configuration before it is used to create the SessionFactory.

      I ran in to this problem because I need to override the connection url, user and password properties in test cases (so that an in-memory HSQLDB database can be used). I am sure that there will be other scenarios where properties will need to be overriden at run time,

      Access to the Configuration object might not be sensible. An alternative would be the ability to provide names and values that are then set in the Configuration before SessionFactory creation.

        Activity

        Hide
        Dan Adams added a comment -

        I was actually going to put in an enhancement ticket requesting more or less the same thing but for a different reason; I need access to the configuration before the session factory is created in order to do things like adding hibernate event listeners. In general I think it makes sense for configuration of the session factory to be distributed just as contributing entities and entity packages is.

        Show
        Dan Adams added a comment - I was actually going to put in an enhancement ticket requesting more or less the same thing but for a different reason; I need access to the configuration before the session factory is created in order to do things like adding hibernate event listeners. In general I think it makes sense for configuration of the session factory to be distributed just as contributing entities and entity packages is.
        Hide
        Dan Adams added a comment -

        I'm raising the priority because this feature is actually pretty crucial to something I need to do with this. I think that the module needs to be fairly robust or else I'm going to have to do something like duplicate it into my project to make the necessary features available which I don't want to do.

        Show
        Dan Adams added a comment - I'm raising the priority because this feature is actually pretty crucial to something I need to do with this. I think that the module needs to be fairly robust or else I'm going to have to do something like duplicate it into my project to make the necessary features available which I don't want to do.
        Hide
        Dan Adams added a comment -

        I attached a patch that adds a pipleline filter for adding contributions that modify the hibernate configuration before the session factory is created. This should allow both the adding of properties as well as more complicated things like adding event handlers. I also moved the default configuration of calling Configuration.configure() and adding the entity packages based on contributed package names out to separate classes that are then contributed by HibernateModule. How hibernate is configured is now very configurable and the session source that creates the session factory is now very lightweight.

        Show
        Dan Adams added a comment - I attached a patch that adds a pipleline filter for adding contributions that modify the hibernate configuration before the session factory is created. This should allow both the adding of properties as well as more complicated things like adding event handlers. I also moved the default configuration of calling Configuration.configure() and adding the entity packages based on contributed package names out to separate classes that are then contributed by HibernateModule. How hibernate is configured is now very configurable and the session source that creates the session factory is now very lightweight.
        Hide
        Dan Adams added a comment -

        I alternate way to do it other than the way my patch does it that I think might be better would be to use only HibernateConfigurer instances rather than having a configuration specifically for packages. Rather we could have a facade class with factory methods for creating instances for adding packages, entities, etc.

        Show
        Dan Adams added a comment - I alternate way to do it other than the way my patch does it that I think might be better would be to use only HibernateConfigurer instances rather than having a configuration specifically for packages. Rather we could have a facade class with factory methods for creating instances for adding packages, entities, etc.
        Hide
        Howard M. Lewis Ship added a comment -

        I'd like to apply the patch, but it doesn't apply cleanly ... even after adjusting imports, there seems to be some missing stuff. Was the patch made from an earlier version of the code? Can a new patch be created?

        Show
        Howard M. Lewis Ship added a comment - I'd like to apply the patch, but it doesn't apply cleanly ... even after adjusting imports, there seems to be some missing stuff. Was the patch made from an earlier version of the code? Can a new patch be created?
        Hide
        Dan Adams added a comment -

        Where are the conflicts? I created the patch against revision 547489. I can try and apply the patch myself and then update and make a new one later this afternoon.

        Show
        Dan Adams added a comment - Where are the conflicts? I created the patch against revision 547489. I can try and apply the patch myself and then update and make a new one later this afternoon.
        Hide
        Dan Adams added a comment -

        Here's another attempt at creating the patch after updating. I think you should still try and use the first patch as I had some weirdness creating this one.

        Some problems you may have hit with the first one:

        • i'm using eclipse
        • i checked out the tapestry-hibernate module as it's own project called "tapestry-hibernate2" because i already had another copy of it for another patch. So you should apply the patch directly to tapestry-hiberate at the level that it gets rid of the tapestry-hibernate2

        so I would suggest trying the first one again and then maybe this one.

        Show
        Dan Adams added a comment - Here's another attempt at creating the patch after updating. I think you should still try and use the first patch as I had some weirdness creating this one. Some problems you may have hit with the first one: i'm using eclipse i checked out the tapestry-hibernate module as it's own project called "tapestry-hibernate2" because i already had another copy of it for another patch. So you should apply the patch directly to tapestry-hiberate at the level that it gets rid of the tapestry-hibernate2 so I would suggest trying the first one again and then maybe this one.
        Hide
        Dan Adams added a comment -

        Also, a note about the first patch: I'm accepting the license agreement even though it says i didn't. It says that because I attached it through mylar and the option doesn't exist there.

        Show
        Dan Adams added a comment - Also, a note about the first patch: I'm accepting the license agreement even though it says i didn't. It says that because I attached it through mylar and the option doesn't exist there.
        Hide
        Dan Adams added a comment -

        Housekeeping.

        Show
        Dan Adams added a comment - Housekeeping.

          People

          • Assignee:
            Dan Adams
            Reporter:
            Mike D Pilsbury
          • Votes:
            1 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development