That’s not a problem,

 

Just model an operation on the classifier scope of that entity, but do *not* assign it the FinderMethod stereotype.

This will place the operation as an entity business operation in the DAO, that way you’ll have a finder method that you can implement yourself.

 

Here’s an example:

 

    protected List handleSearch(ArticleSearchCriteria searchCriteria) throws ArticleException

    {

        try

        {

            final Session session = getSession();

            Criteria articleCriteria = getHibernateTemplate().createCriteria(session, ArticleImpl.class);

 

            if (StringUtils.isNotBlank(searchCriteria.getBarCode()))

            {

                articleCriteria.add(_expression_.eq("barCode", searchCriteria.getBarCode()));

            }

 

            if (searchCriteria.getType() != null)

            {

                Criteria typeCriteria = articleCriteria.createCriteria("type");

                typeCriteria.add(_expression_.eq("id", searchCriteria.getType()));

            }

 

            List list = articleCriteria.list();

            this.closeSessionIfNecessary(session);

 

            toArticleListItem(list);

            return list;

        }

        catch (Exception e)

        {

            throw new ArticleException("Searching for articles failed", e);

        }

    }

 

 

-- Wouter

 


From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Chris Sterling
Sent: Monday, January 17, 2005 9:19 PM
To: AndroMDA Users Mailing List
Subject: [Andromda-user] getHibernateTemplate from outside Dao

 

We are currently having an issue of getting access to the Hibernate template from a class other than the *DaoBase class which extends HibernateDaoSupport.  The reason for this access is to create a special criteria that we can use to find an object by a String ignoring case.

Is there any default to get access to the template from another class?

 
-- 
Chris Sterling
Software Architect
Codesic Consulting
[EMAIL PROTECTED]
office: 425-576-9292

 

Reply via email to