Derek Broughton wrote:
Rob Hills wrote:

Make sure your DAO attributes are references to the Interface rather
than the Hibernate implementation.  For example, if you've got a UtoDao
interface and a UtoDaoHibernate class, your manager should include
something like this:

UtoDao utoDao;

public void setUtoDao(UtoDao utoDao) {
    this.utoDao = utoDao;
}

is this supposed to work for the Action tests? I found I had to manually get
those the same way I get the manager.
That's correct.  In my Action tests, I had to manually inject DAOs
It's not working for me outside the Tests at all.  No doubt something really
stupid, but I am trying to get both my account and transaction DAOs and
getting nulls:

public class JournalentryManagerImpl extends
GenericManagerImpl<Journalentry, Long> implements JournalentryManager{
    JournalentryDao dao;
    private GltransactionDao gltransactionDao;
...
        /**
         * @return the gltransactionDao
         */
        public GltransactionDao getGltransactionDao() {
                return gltransactionDao;
        }

        /**
         * @param gltransactionDao the gltransactionDao to set
         */
        public void setGltransactionDao(GltransactionDao gltransactionDao) {
                this.gltransactionDao = gltransactionDao;
        }
        @Override
        public Journalentry save(Journalentry object) {
                if (object.getTransaction() == null){
                        Gltransaction trans = gltransactionDao.save(new
Gltransaction());
This isn't related to the main problem you're having, but if you've correctly defined the relationship between Gltransaction and Journalentry in the model classes, then you don't need to do the gltransactionDao.save() bit. Just instantiate the transaction and add it to the Journalentry (as you do in the following line).
                        object.setTransaction(trans);
                }
                return super.save(object);
        }

and in ApplicationContext.xml:
<bean id="gltransactionDao"
class="ca.pointerstop.cocoa.dao.hibernate.GltransactionDaoHibernate">
        <property name="sessionFactory" ref="sessionFactory"/>
</bean> <bean id="gltransactionManager"
class="org.appfuse.service.impl.GenericManagerImpl">
        <constructor-arg ref="gltransactionDao"/>
</bean>

Surely the generic manager is sufficient here?
Yes, if you don't need to add any extra functionality to the manager then the generic one will be fine.
  In fact, Glaccount _does_
have its own manager, but the problem is the same.
<bean id="glaccountDao"
class="ca.pointerstop.cocoa.dao.hibernate.GlaccountDaoHibernate">
        <property name="sessionFactory" ref="sessionFactory"/>
</bean> <bean id="glaccountManager"
class="ca.pointerstop.cocoa.service.impl.GlaccountManagerImpl">
        <constructor-arg ref="glaccountDao"/>
</bean>


In any case, in my overridden save() method, when "object.getTransaction()"
is null, it tries to save a new Gltransaction, but gltransactionDao is
null.

In a quick glance through your code, I can't see anything obvious wrong with it so I believe you're basically on the right track. I don't have time right now to go through it in fine detail, but will hopefully be able to do so a bit later this morning (in 3-4 hours). Meanwhile, I'd probably:

1. Look very closely at the logs generated when you start up your app - there may be a clue there. Investigate any errors that appear even if they're not obviously related; 2. Go through your applicationContext.xml (btw you called it ApplicationContext.xml, I assume that was a typo, from memory the first letter should be lowercase) with a fine tooth comb - particularly look for incorrect case and typos.

Good luck,

Rob Hills
Waikiki, Western Australia

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to