cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From WHIRLYCOTT <p...@whirlycott.com>
Subject Re: [flow] Hibernate createCriteria syntax help?
Date Wed, 26 Jan 2005 19:10:58 GMT
If you will allow me to offer to you a thought which is only slightly 
related to your original question, I would strongly encourage you to 
move all of that transactional persistence stuff behind a facade a for a 
few reasons, listed in no particular order:

1) you'll be able to write junit tests to see if the backend is behaving
2) decouple your application layers into something resembling MVC
3) If you decide one day to use something other than Hibernate, you will 
  be able to rip out the persistence mechanism without touching your 
flow controllers
4) you can reuse your facade in other applications

etc.

All I am suggesting to you is that your flow code goes against a facade 
like this:

	...
	var myFacade = new ApplicationFacade();
	var bug = myFacade.getBugsByStatus('UNCONFIRMED');
	myFacade.close();
	...

The flow doesn't know or care that Hibernate/OJB/SOAP/JDO/JDBC/foo is 
behind the facade, which is precisely the point.  Business logic 
shouldn't live in flow.

phil.

JD Daniels wrote:
> Hi all,
> 
> I am trying to add criteria inside a flowscript. Here is what i think 
> should work:
> 
> 1        var criteria = hs.createCriteria(Bug.class);
> 2       criteria.add(Expression.eq("status", "UNCONFIRMED"));
> 3        var bug = criteria.list();
> 
> this spits out : missing name after . operator on line 1
> 
> I have tried variations of switching to the the [""] syntax of calling 
> methods, but while they fix the error, criteria is always undefined.
> 
> Anyone have insight into how i can call these methods in flow?
> 
> full function:
> 
> function search_bug()
> {
>        // Create The Form
>        var form = new Form("forms/bugSearchModel.xml");
> 
>        // Set Some Form Specific Text Fields
>        var model = form.getWidget();
>        model.buttonText = "Search";
>        model.title = "Search Bug Database";
> 
>        form.showForm("internal/show-form/bugSearch");
> 
>        // Create Hibernate Session
>        var factory = 
> cocoon.getComponent(Packages.com.kismetsoftware.insecticide.PersistenceFactory.ROLE);

> 
>        var hs = factory.createSession();
> 
>        // Might as well quit now if the session is no good :(
>        if (hs == null){throw new 
> Packages.org.apache.cocoon.ProcessingException("Hibernate session is 
> null ");}
> 
>        // This is problem Line:
>        var criteria = hs.createCriteria(Bug.class);
>        criteria.add(Expression.eq("status", "UNCONFIRMED"));
>        var bug = criteria.list();
> 
>        // Clean Up Our Mess :)
>        hs.flush();
>        hs.close();
>        cocoon.releaseComponent(factory);
> 
>        // Send The User Their Result
>        cocoon.sendPage("internal/generate-view/bug_summary", {title : 
> "Bugs",bug : bug});
> }
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
> 

-- 
                                   Whirlycott
                                   Philip Jacob
                                   phil@whirlycott.com
                                   http://www.whirlycott.com/phil/

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Mime
View raw message