Tapestry 5
  1. Tapestry 5
  2. TAP5-48

Let Tapestry - Hibernate connect to multiple databases

    Details

    • Type: New Feature New Feature
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 5.0.15
    • Fix Version/s: None
    • Component/s: tapestry-hibernate
    • Labels:
      None
    • Environment:
      All

      Description

      Tapestry - Hibernate integration should include mechanism to connect to multiple databases via named sessions.

        Activity

        Hide
        Wolf Dieter Auer added a comment -

        Sehr geehrte Damen und Herrn!

        Vielen Dank für Ihre Nachricht.

        Ich bin wieder ab 7. Jan. im Büro erreichbar.

        Frohe Weihnachten und guten Rutsch
        Wolf Dieter Auer

        Show
        Wolf Dieter Auer added a comment - Sehr geehrte Damen und Herrn! Vielen Dank für Ihre Nachricht. Ich bin wieder ab 7. Jan. im Büro erreichbar. Frohe Weihnachten und guten Rutsch Wolf Dieter Auer
        Hide
        Bob Harner added a comment -

        See http://java.dzone.com/articles/tapestry-magic-integrating for an implementation.

        Also, the Tapestry-JPA module (http://tapestry.apache.org/integrating-with-jpa.html) supports multiple databases starting with Tapestry 5.3.

        Show
        Bob Harner added a comment - See http://java.dzone.com/articles/tapestry-magic-integrating for an implementation. Also, the Tapestry-JPA module ( http://tapestry.apache.org/integrating-with-jpa.html ) supports multiple databases starting with Tapestry 5.3.
        Hide
        Paul Stanton added a comment -

        @Pierce Wetter

        can you give a couple of hints on how to do this with JPA? does tapestry-hibernate already look at persistence.xml for configuration? if not how can i configure it so that it does?

        or are you talking hypothetically if tapestry-hibernate was modified to be compatible?

        Show
        Paul Stanton added a comment - @Pierce Wetter can you give a couple of hints on how to do this with JPA? does tapestry-hibernate already look at persistence.xml for configuration? if not how can i configure it so that it does? or are you talking hypothetically if tapestry-hibernate was modified to be compatible?
        Hide
        Pierce Wetter added a comment -

        This could be done using JPA instead, and it wouldn't affect your configuration vs. convention objection because multiple persistence units could be defined in persistence.xml.

        Show
        Pierce Wetter added a comment - This could be done using JPA instead, and it wouldn't affect your configuration vs. convention objection because multiple persistence units could be defined in persistence.xml.
        Hide
        Davor Hrg added a comment -

        It might be usefull to take look at
        Hibernate Shards
        http://hibernate.org/414.html

        this way hibernate handles multiple database logic,
        you can most likely avoid mess one could generate by
        having multiple hibernate instances (SessionFactory)

        this doesn't have to solve everyones problem
        but might be usefull to many needing multiple database access

        I don't have much insight in this

        Show
        Davor Hrg added a comment - It might be usefull to take look at Hibernate Shards http://hibernate.org/414.html this way hibernate handles multiple database logic, you can most likely avoid mess one could generate by having multiple hibernate instances (SessionFactory) this doesn't have to solve everyones problem but might be usefull to many needing multiple database access I don't have much insight in this
        Hide
        Jonathan Barker added a comment -

        I'm using Spring, and in about a third of what I do, I need multiple connections. It's one of the reasons I have not been motivated to move away from Spring.

        Some cases could be handled with specification of schema and catalog to use multiple databases within the same server on the same Session; others are on different servers with different database engines.

        There is usually one primary DB that I want to configure with as little effort as possible, and the corresponding SessionFactory gets autowired into my DAO's. The other SessionFactory(s) I specify are not for autowiring so I don't get grumbling about multiple SessionFactories.

        It would be good to have "First Class" support for this functionality.

        Show
        Jonathan Barker added a comment - I'm using Spring, and in about a third of what I do, I need multiple connections. It's one of the reasons I have not been motivated to move away from Spring. Some cases could be handled with specification of schema and catalog to use multiple databases within the same server on the same Session; others are on different servers with different database engines. There is usually one primary DB that I want to configure with as little effort as possible, and the corresponding SessionFactory gets autowired into my DAO's. The other SessionFactory(s) I specify are not for autowiring so I don't get grumbling about multiple SessionFactories. It would be good to have "First Class" support for this functionality.
        Hide
        Ville Virtanen added a comment -

        I thought that it would be possible to implement it so that if developer needs to connect to only one database everything would be exactly as now.

        Connecting to other databases would be possible if developer added one more hibernate.cfg.xml file. The second file should be named hibernateIdentifier.cfg.xml. Also entities package should be entities.identifier.

        Without identifier Tapestry would create the normal session that can be Injected using just
        @Inject
        private Session session

        The other session(s) should be accessed using
        @Inject
        @Service("Identifier")
        private Session identifierSession

        I don't know if this is too far-fetched, but I'm just adding this like I would like to use it. And this would be consistent approach with the convention over configuration way of thinking.

        This would introduce new things to @CommitAfter handling ofcourse (commit all session instance's transactions) and it should also introduce new annotation (Or parameter to @CommitAfter) witch would ofcourse be @CommitAfter(value="identifier1,identifier2")

        Show
        Ville Virtanen added a comment - I thought that it would be possible to implement it so that if developer needs to connect to only one database everything would be exactly as now. Connecting to other databases would be possible if developer added one more hibernate.cfg.xml file. The second file should be named hibernateIdentifier.cfg.xml. Also entities package should be entities.identifier. Without identifier Tapestry would create the normal session that can be Injected using just @Inject private Session session The other session(s) should be accessed using @Inject @Service("Identifier") private Session identifierSession I don't know if this is too far-fetched, but I'm just adding this like I would like to use it. And this would be consistent approach with the convention over configuration way of thinking. This would introduce new things to @CommitAfter handling ofcourse (commit all session instance's transactions) and it should also introduce new annotation (Or parameter to @CommitAfter) witch would ofcourse be @CommitAfter(value="identifier1,identifier2")
        Hide
        Howard M. Lewis Ship added a comment -

        That's the kind of trade off that I'm not super interested in; it means some amount of extra configuration for the more general case: that there is just one database to connect to. What is more useful, perhaps, is a way to reuse the tapestry-hibernate code to build a solution that you need.

        Show
        Howard M. Lewis Ship added a comment - That's the kind of trade off that I'm not super interested in; it means some amount of extra configuration for the more general case: that there is just one database to connect to. What is more useful, perhaps, is a way to reuse the tapestry-hibernate code to build a solution that you need.

          People

          • Assignee:
            Unassigned
            Reporter:
            Ville Virtanen
          • Votes:
            13 Vote for this issue
            Watchers:
            16 Start watching this issue

            Dates

            • Created:
              Updated:

              Development