An actionDao ? ... its make no sense for me (Sorry): Action =
Controller Layer, Dao = Persistence Layer .
Jonathan Dray wrote:
Matt,
I have successfully tested my actionDao with an appfuse test case :
BaseDaoTestCase.
The problem is that now I want to test my manager which doesn't
inherit an Appfuse class.
I tried to test it in an AbstractTransactionalSpringContextTest class.
My manager is no definded as a Spring Bean, thus I need to provide to
my manager 2 dao instances manually :
- an actionDao
- a processDao
These two Daos are defined as beans in my applicationContext and both
inherit a GenericDao appfuse dao class .
To get these two beans in my manager's test I tried 2 different ways :
- use 2 private variables actionDao and processDao and use an
@Autowired annotation and added the necessary configuration to spring
to use annotations.
- use 2 private variables actionDao and processDao and implement
setters these variables.
Both failed with sessionFactory related problem.
I'm quite new to Hibernate, Spring and Appfuse and may have missed
something important.
Thanks for your patience.
Jonathan
2008/8/11 Matt Raible <[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]>>
It looks like your DAO may be the problem. Have you successfully
written a test for it? You should make sure your
ActionDaoHibernate extends HibernateTemplate or one of the AppFuse
base classes.
Matt
On Mon, Aug 11, 2008 at 9:14 AM, Jonathan Dray
<[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>> wrote:
Hi Matt,
I've tested AbstractTransactionalSpringContextTests and got
some errors while Spring tries to load my daos :
Error creating bean with name 'actionDao' defined in class
path resource [ApplicationContext-resources.xml]: Cannot
resolve reference to bean 'sessionFactory' while setting bean
property 'sessionFactory'; nested exception is
org.springframework.beans.factory.NoSuchBeanDefinitionException:
No bean named 'sessionFactory' is defined
Do I have to provide all the informations as if I was
configuring hibernate with Spring (without appfuse) ?
- Defining a session factory that uses my datasource?
- Handling transactions with AOP ?
If it is the case :
Is there an appfuse base manager class that my manager should
inherit and that will handle all this ?
Did I miss something ?
Thanks for your help.
Regards,
Jonathan Dray
2008/8/8 Matt Raible <[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]>>
Running your DAOs outside of a transaction is what's
causing your lazy
exceptions. By extending the Spring classes, your test
methods will be
wrapped in transactions. As for your Managers when running
in Tomcat,
if they exist under the "service" package (at any level)
and they end
in "Manager", their methods should be wrapped in
transactions too.
Matt
On Fri, Aug 8, 2008 at 1:20 AM, Jonathan Dray
<[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>>
wrote:
> Hi Matt,
>
> Ok, I will try to extend the spring test class you
suggested.
> But what about in my application ?
>
> As my manager doesn't extend an Appfuse manager class
I'll probably have
> some errors .
> Do I have to define additional configuration options
(transactions, lazy
> loading) in spring or hibernate configuration files ?
> If it is the case do you some examples on how to do this
please ?
>
> Thank you.
> Best Regards,
>
> Jonathan Dray
>
>
> 2008/8/8 Matt Raible <[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]>>
>>
>> You should change your test class to extend Spring's
>> AbstractTransactionalDataSourceSpringContextTests (or
something like
>> that).
>>
>> Matt
>>
>> On Thu, Aug 7, 2008 at 5:34 PM, Jonathan Dray
<[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>>
>> wrote:
>> > Hi,
>> >
>> > We are working with Appfuse and we really appreciate it.
>> > We have defined a custom manager that uses several daos.
>> > It does not extends any of appfuse manager classes.
>> >
>> > It perfectly works in a test case when the test class
used extends one
>> > of
>> > Appfuse test classes available.
>> > We followed indications found in this thread :
>> >
>> >
http://www.nabble.com/-Appfuse2.0--Best-Practise-Design-Pattern-for-Multiple-Dao-Access-from-managers-td14116309s2369.html#a14370264
>> >
>> > But, we get some errors when we try to test the same
manager with a
>> > Junit or
>> > a Spring Test Case.
>> > The errors are about lazy loading.
>> >
>> > How should we define our custom manager so that it
works without a
>> > specific
>> > appfuse context ?
>> > There must be some best practices to do this with
appfuse. Could you
>> > please
>> > give us more information on how to handle this ?
>> >
>> > Thank you.
>> >
>> > Regards,
>> > Jonathan Dray
>> >
>>
>>
---------------------------------------------------------------------
>> To unsubscribe, e-mail:
[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]>
>> For additional commands, e-mail:
[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]>
>>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail:
[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail:
[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]>
--
Leo Barrientos C.
Master en IngenierÃa de Software.
Open Sistemas de Información Internet
Fono: +34 902 10 73 96
Correo: [EMAIL PROTECTED]
Web: http://www.opensistemas.com
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]