[
https://issues.jboss.org/browse/FORGE-372?page=com.atlassian.jira.plugin....
]
Paul Dijou commented on FORGE-372:
----------------------------------
Hi,
In fact, I've test several solutions in the last few days and find some solutions. The
main question is : do you want Forge plugins to use the EntityManager provided by Forge
(in its package) or the "default" EntityManager of the application (define by
the user) ? The first one is probably safer since you know exactly how the EntityManager
is parametrized, but the second one seems more logic since it's the user's
application, so if he wants an extended Seam EntityManager, good for him, the plugins
should use it too (hoping all will be good).
In the first case, easy to do : add a qualifier on the producer of the Forge
EntityManager, add it also on the @Inject point, and you're done.
In the second case, I have several propositions :
1) Delete the DatasourceProducer class in your package and generate it when the user
initialize the project : in this configuration, the user can override it or delete it
without any problem. A new command in the console like "restore
datasourceProducer" would delete and re-create DatasourceProducer class with the
default configuration provide by Forge.
2) Keep the DatasourceProducer class in your package but add an @Alternative annotation in
the producer and put it in the beans.xml alternative list. So the day the user want to use
it's own EntityManager, he just has to edit the beans.xml and remove the correct
line.
3) There is also a solution by adding an @Veto annotation at runtime with Seam Solder but
since, perhaps, the project does not require Solder, it's not good enough.
In any case, you have to generate something in the user project in order to let him change
it when he needs to.
Hope my french-english will not kill your eyes.
Qualifier on Forge EntityManager
--------------------------------
Key: FORGE-372
URL:
https://issues.jboss.org/browse/FORGE-372
Project: Forge
Issue Type: Enhancement
Components: Scaffold
Affects Versions: 1.0.0.Beta3
Reporter: Paul Dijou
Assignee: Lincoln Baxter III
The EntityManager (same for the EntityManagerFactory) generated by Forge in
org.metawidget.forge.persistence.DatasourceProducer has no Qualifier. It becomes a problem
when I need to create my own EntityManager because they both have the @Default qualifier
and CDI throws an exception. The only solution is to add a qualifier to my EntityManager
but it bother me since I want it to be the default EntityManager.
To reproduce the problem, just install the seam-persistence plugin, ask
"seam-persistence install-managed-persistence-context" and it will generate
another EntityManagerFactory with no qualifier and here is the CDI exception.
Would it be possible to add a qualifier like "@ForgeEntityManager" and
"@ForgeEntityManagerFactory" on the DatasourceProducer class ? (and, of course,
on the PersistenceUtil class too). This way, if a user add it's own EntityManager, it
well be the @Default.
Thanks.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:
https://issues.jboss.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see:
http://www.atlassian.com/software/jira