[
https://issues.apache.org/jira/browse/ARIES-413?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12912952#action_12912952
]
Timothy Ward commented on ARIES-413:
------------------------------------
I'm afraid that that won't work because the setter won't be driven until after
the createFixture method!
Something like this should give the behaviour you're after (Note that you'll
need to use a version of Aries that contains a fix for ARIES-322, i.e. 0.2 or
higher):
<bean id="fixtureInitialiser"
class="se.digia.sts.refdata.test.FixtureInitialiser">
<property name="fixture">
<bean class="se.digia.sts.refdata.test.RefdataFixtureService">
<tx:transaction method="initialise" value="RequiresNew" />
<jpa:context property="entityManager" unitname="refdataPU" />
</bean>
</property>
</bean>
<bean id="fixtureImpl" factory-method="getInitialisedBean"
factory-ref="fixtureInitialiser"/>
public class FixtureInitialiser {
private RefdataFixtureService fixture;
public void setFixture(RefdataFixtureService theFixture) {
fixture = theFixture;
fixture.initialise();
}
public RefdataFixtureService getInitialisedBean() {
return fixture;
}
}
> Injecting an entity manager using factory method
> ------------------------------------------------
>
> Key: ARIES-413
> URL: https://issues.apache.org/jira/browse/ARIES-413
> Project: Aries
> Issue Type: Improvement
> Components: JPA
> Affects Versions: 0.2
> Reporter: Bengt Rodehav
> Assignee: Timothy Ward
>
> It is only possible to use setter injection when injecting a JPA entity
> manager. The following injection types should also be supported since they
> are supported in the Blueprint spec:
> - Constructor injection
> - Factory method injection
> - Factory class injection
> An example of usage could be (using a factory method):
> <bean id="beanImpl" class="MyClass" factory-method="create">
> <argument>
> <jpa:context property="entityManager" unitname="myPU"/>
> </argument>
> </bean>
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.