You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Sébastien ARBOGAST <se...@gmail.com> on 2005/04/08 00:04:15 UTC

Cocoon, Hibernate and HSQL

Hi,

I would like to use the internal HSQL shipped with Cocoon as a SQL
database to persist my POJO's for Hibernate.
I found an excellent tutorial about integration of Hibernate into
Cocoon, but I didn't found anything about configuring a new database
(because there already seems to be one configured by default) with
HSQL on In-Process mode to use it instead of an external database like
MySQL for example.

Has anyone already tried that ? Can you give me a few tips ?

Thanks in advance.

Regards
-- 

Sebastien ARBOGAST

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


Re: Re[2]: Cocoon, Hibernate and HSQL

Posted by Mark Lowe <me...@gmail.com>.
I've just taken a look at the hibernte, cocoon, spring petstore. Looks
like it does precisely what I was saying..

Getting the appContext in flow script seems obvious now I've seen it done.. 

Mark

On Apr 11, 2005 12:08 AM, Mark Lowe <me...@gmail.com> wrote:
> If you want to start the DB with the webapplication then i can think
> of worse things than simply having a DBServer.init() which would also
> allow you to configure parameters in web.xml. Thats about as closely
> as you'd want to couple cocoon to the DB. I'm not sure if HSQLDB
> supported transactions, but should be okay for read access apps. Its
> possible that the hibernate wrappers for the JDBC calls report that
> transactions are working, when the db will tell you otherwise, this is
> the case with mysql when using myisam table engine (depends on who
> wrote the jdbc driver).
> 
> On hibernate.
> I'm not sure how you access the application context in flowscript (if
> thats a problem, I have a feeling that only the cocoon servlet context
> would be avialiable in flowscript), but i'd look around at any notes
> on intgregrating spring with cocoon. This would give you a very clean
> separation, spring makes light work of hibernate, the spring servlet
> places any configured services (means of accessing your hibernated
> objects) and then the trick would just be getting the services in your
> view (in this case cocoon). This would mean no need to have db
> configuration in your view resources (cocoon.xconf etc), but rather in
> spring.
> 
> I'd have a look for one of the numberous examples on hibernate and
> spring, and then look for folk who have used spring with cocoon. It
> must be doable.
> 
> "The Hibernate builtin connection pool is for testing purposes only. It
> might work on some databases, but I definately saw it break on MySQL
> when leaving it running overnight."
> 
> Regarding the connection pooling breaking on mysql, this could be the
> mysql driver rather than the hibernate's default pooling (commons dbcp
> i believe, although not entirly sure). There were a few pesky drivers
> around with mysql that where causing strife for a while. I've used
> hibernate with mysql and postgres without issue (other than the weeks
> tracking down the jdbc issue), both with spring and a more standard
> hibernate way.
> 
> Mark
> 
> 
> On Apr 9, 2005 5:57 PM, Grzegorz Sikora <sz...@op.pl> wrote:
> > Hello Sebastien,
> >
> > Saturday, April 9, 2005, 4:42:04 PM, you wrote:
> >
> > SA> - What is the URL of my HSQLDB database ?
> > SA> - How can I configure it to tell him for example where to put its files ?
> > SA> I know I can find information about that in HSQLDB documentation but
> > SA> here as I'd like my database to be embedded in my web application, I
> > SA> guess there is somewhere in Cocoon where I have to add code to
> > SA> initialize it when Cocoon is started...
> > SA> Any ideas ? Or at least has somebody already successfully used that
> > SA> configuration ?
> >
> > Search for hsqldb-server tag and datasources tag both in
> > cocoon.xconf.
> >
> > --
> > Best regards,
> >  Grzegorz Sikora
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> > For additional commands, e-mail: users-help@cocoon.apache.org
> >
> >
>

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


Re: Re[2]: Cocoon, Hibernate and HSQL

Posted by Mark Lowe <me...@gmail.com>.
If you want to start the DB with the webapplication then i can think
of worse things than simply having a DBServer.init() which would also
allow you to configure parameters in web.xml. Thats about as closely
as you'd want to couple cocoon to the DB. I'm not sure if HSQLDB
supported transactions, but should be okay for read access apps. Its
possible that the hibernate wrappers for the JDBC calls report that
transactions are working, when the db will tell you otherwise, this is
the case with mysql when using myisam table engine (depends on who
wrote the jdbc driver).

On hibernate.
I'm not sure how you access the application context in flowscript (if
thats a problem, I have a feeling that only the cocoon servlet context
would be avialiable in flowscript), but i'd look around at any notes
on intgregrating spring with cocoon. This would give you a very clean
separation, spring makes light work of hibernate, the spring servlet
places any configured services (means of accessing your hibernated
objects) and then the trick would just be getting the services in your
view (in this case cocoon). This would mean no need to have db
configuration in your view resources (cocoon.xconf etc), but rather in
spring.

I'd have a look for one of the numberous examples on hibernate and
spring, and then look for folk who have used spring with cocoon. It
must be doable.

"The Hibernate builtin connection pool is for testing purposes only. It
might work on some databases, but I definately saw it break on MySQL
when leaving it running overnight."

Regarding the connection pooling breaking on mysql, this could be the
mysql driver rather than the hibernate's default pooling (commons dbcp
i believe, although not entirly sure). There were a few pesky drivers
around with mysql that where causing strife for a while. I've used
hibernate with mysql and postgres without issue (other than the weeks
tracking down the jdbc issue), both with spring and a more standard
hibernate way.

Mark


On Apr 9, 2005 5:57 PM, Grzegorz Sikora <sz...@op.pl> wrote:
> Hello Sebastien,
> 
> Saturday, April 9, 2005, 4:42:04 PM, you wrote:
> 
> SA> - What is the URL of my HSQLDB database ?
> SA> - How can I configure it to tell him for example where to put its files ?
> SA> I know I can find information about that in HSQLDB documentation but
> SA> here as I'd like my database to be embedded in my web application, I
> SA> guess there is somewhere in Cocoon where I have to add code to
> SA> initialize it when Cocoon is started...
> SA> Any ideas ? Or at least has somebody already successfully used that
> SA> configuration ?
> 
> Search for hsqldb-server tag and datasources tag both in
> cocoon.xconf.
> 
> --
> Best regards,
>  Grzegorz Sikora
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
> 
>

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


Re[2]: Cocoon, Hibernate and HSQL

Posted by Grzegorz Sikora <sz...@op.pl>.
Hello Sebastien,

Saturday, April 9, 2005, 4:42:04 PM, you wrote:

SA> - What is the URL of my HSQLDB database ?
SA> - How can I configure it to tell him for example where to put its files ?
SA> I know I can find information about that in HSQLDB documentation but
SA> here as I'd like my database to be embedded in my web application, I
SA> guess there is somewhere in Cocoon where I have to add code to
SA> initialize it when Cocoon is started...
SA> Any ideas ? Or at least has somebody already successfully used that
SA> configuration ?

Search for hsqldb-server tag and datasources tag both in
cocoon.xconf.

-- 
Best regards,
 Grzegorz Sikora


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


Re: Cocoon, Hibernate and HSQL

Posted by Sebastien Arbogast <se...@gmail.com>.
Actually I was thinking of using your excellent tutorial Johannes but
my problem is rather with the configuration of a HSQLDB database
inside Cocoon to use it for your tutorial with Cocoon connection
pooling. It's the first time I try to use an embedded database. And I
have questions like :
- What is the URL of my HSQLDB database ?
- How can I configure it to tell him for example where to put its files ?
I know I can find information about that in HSQLDB documentation but
here as I'd like my database to be embedded in my web application, I
guess there is somewhere in Cocoon where I have to add code to
initialize it when Cocoon is started...
Any ideas ? Or at least has somebody already successfully used that
configuration ?

Thanks in advance

On Apr 9, 2005 9:31 AM, Johannes Textor <jc...@gmx.de> wrote:
> Leszek Gawron schrieb:
> 
> > You can put all your database configuration data in hibernate.cfg.xml
> > and it will work just fine. No need to use cocoon connection pools.
> 
> Although this is slightly offtopic, I'd like to give my 2c on this
> (since it would mean that my poor tutorial would be useless ;) ):
> 
> The Hibernate builtin connection pool is for testing purposes only. It
> might work on some databases, but I definately saw it break on MySQL
> when leaving it running overnight. AFAIK, Hibernate is designed to work
> with an extern implementation of connection pooling, and supplies its
> own pooling just to get people started quicker.
> 
> One more reason to use cocoon connection pooling might be that you might
> find it a little nicer to have one central place to put your database
> credentials and have only one pooling implementation running in your
> webapp. The cocoon builtin connection pool was the first thing that came
> into my mind when I implemented this.
> 
> As far as I am aware of it, most people prefer using Swing and C3PO
> instead, but few stick around with the Hibernate builtin pool, at least
> not when putting the app into production.
> 
> Thoughts ?
> 
> Regards,
> Johannes
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
> 
> 


-- 
Sebastien ARBOGAST

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


Re: Cocoon, Hibernate and HSQL

Posted by Johannes Textor <jc...@gmx.de>.
Leszek Gawron schrieb:

> You can put all your database configuration data in hibernate.cfg.xml 
> and it will work just fine. No need to use cocoon connection pools.

Although this is slightly offtopic, I'd like to give my 2c on this 
(since it would mean that my poor tutorial would be useless ;) ):

The Hibernate builtin connection pool is for testing purposes only. It 
might work on some databases, but I definately saw it break on MySQL 
when leaving it running overnight. AFAIK, Hibernate is designed to work 
with an extern implementation of connection pooling, and supplies its 
own pooling just to get people started quicker.

One more reason to use cocoon connection pooling might be that you might 
find it a little nicer to have one central place to put your database 
credentials and have only one pooling implementation running in your 
webapp. The cocoon builtin connection pool was the first thing that came 
into my mind when I implemented this.

As far as I am aware of it, most people prefer using Swing and C3PO 
instead, but few stick around with the Hibernate builtin pool, at least 
not when putting the app into production.

Thoughts ?

Regards,
Johannes

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


Re: Cocoon, Hibernate and HSQL

Posted by Leszek Gawron <lg...@apache.org>.
Sébastien ARBOGAST wrote:
> Hi,
> 
> I would like to use the internal HSQL shipped with Cocoon as a SQL
> database to persist my POJO's for Hibernate.
> I found an excellent tutorial about integration of Hibernate into
> Cocoon, but I didn't found anything about configuring a new database
> (because there already seems to be one configured by default) with
> HSQL on In-Process mode to use it instead of an external database like
> MySQL for example.
> 
> Has anyone already tried that ? Can you give me a few tips ?
You can put all your database configuration data in hibernate.cfg.xml 
and it will work just fine. No need to use cocoon connection pools.

-- 
Leszek Gawron                                                 MobileBox
lgawron@apache.org                              http://www.mobilebox.pl

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


Re: Cocoon, Hibernate and HSQL

Posted by Grzegorz Sikora <sz...@op.pl>.
Hello Sébastien,

Friday, April 8, 2005, 12:04:15 AM, you wrote:

SA> Hi,

SA> I would like to use the internal HSQL shipped with Cocoon as a SQL
SA> database to persist my POJO's for Hibernate.
SA> I found an excellent tutorial about integration of Hibernate into
SA> Cocoon, but I didn't found anything about configuring a new database
SA> (because there already seems to be one configured by default) with
SA> HSQL on In-Process mode to use it instead of an external database like
SA> MySQL for example.

SA> Has anyone already tried that ? Can you give me a few tips ?

SA> Thanks in advance.

There is no difference in configuration in-process or external
database. Just create and configure correct jdbc connection in
cocoon.xconf. Also you probably have to change Dialect in
hibernate.xml.cfg to HSQL and that's it. Read HB manual.

Avoid specifing connection details in hibernate.cfg.xml'cause as hb doc its
for quick test and learning purposes only. Use db connection pooli ntegrated in Cocoon.


-- 
Best regards,
 Grzegorz Sikora


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