[jbossseam-issues] [JBoss JIRA] Updated: (JBSEAM-2095) Document Multiple DataSources in same with example

Ian Darwin (JIRA) jira-events at lists.jboss.org
Fri Oct 12 19:07:03 EDT 2007


     [ http://jira.jboss.com/jira/browse/JBSEAM-2095?page=all ]

Ian Darwin updated JBSEAM-2095:
-------------------------------

        Summary: Document Multiple DataSources in same with example  (was: Multiple DataSources in same EAR, hib2ddl and import.sql run on all)
     Issue Type: Patch  (was: Feature Request)
    Description: 
When using multiple DataSources in an EJB3 EAR, as suggested by Gavin the the URL referenced below, using Hibernate as the underlying persistence, it appears that the "schema export" and the /import.sql get applied to both.

The workaround is to be sure you only use hbm2ddl auto on one of the datasources.

The attachment gives an example.

  was:
When using multiple DataSources in an EJB3 EAR, as suggested by Gavin the the URL referenced below, using Hibernate as the underlying persistence, it appears that the "schema export" and the /import.sql get applied to both.

It would be nice if there could be a more fine-grained mechanism for associating import.sql and hbm2ddl with particular entities.

I have two Datasources, call them "all" and "bugs" (the idea being that the bugs database will be shared by all developers and should be permanent, whereas the "all" database should be dropped and recreated/imported
each tim).

16:07:55,345 INFO  [SchemaExport] Running hbm2ddl schema export
16:07:55,345 INFO  [SchemaExport] exporting generated schema to database
16:07:55,504 INFO  [SchemaExport] Executing import script: /import.sql
16:07:55,568 INFO  [SchemaExport] schema export complete
...
16:07:55,710 INFO  [SchemaExport] Running hbm2ddl schema export
16:07:55,711 INFO  [SchemaExport] exporting generated schema to database
16:07:55,857 INFO  [SchemaExport] Executing import script: /import.sql
16:07:55,911 INFO  [SchemaExport] schema export complete

It would be most convenient if one could specify more precisely which entities go in which Schema.
I have added the @PersistenceContext annotation on the BugsHome class' EntityManager:

    @PersistenceUnit(name="tcpseambug")
    @In EntityManager bugEntityManager;

    public EntityManager getEntityManager() { return bugEntityManager; }

Note that if I disable the hbm2ddl export on the "bugs" database, then schema setup quits when one of the tables in the "all" database shows up missing.

N.B. Will be happy to write up a complete example for the Reference Manual once this is working :-), as there are several related questions on the Forums.


> Document Multiple DataSources in same with example
> --------------------------------------------------
>
>                 Key: JBSEAM-2095
>                 URL: http://jira.jboss.com/jira/browse/JBSEAM-2095
>             Project: JBoss Seam
>          Issue Type: Patch
>          Components: Core
>    Affects Versions: 2.0.0.CR1
>         Environment: EAR deployment, POJO beans setup by Seam-Gen. OS not relevant; tried JDK1.6 and 1.7EA. DB is PostgreSQL 8.
>            Reporter: Ian Darwin
>         Attachments: multiple_datasources.xml
>
>
> When using multiple DataSources in an EJB3 EAR, as suggested by Gavin the the URL referenced below, using Hibernate as the underlying persistence, it appears that the "schema export" and the /import.sql get applied to both.
> The workaround is to be sure you only use hbm2ddl auto on one of the datasources.
> The attachment gives an example.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the seam-issues mailing list