You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Jonny Pony <jo...@hotmail.com> on 2005/04/11 10:40:12 UTC

Questions on CHS (Cocoon, Hibernate, Spring) petstore project

Hi,

I've got a couple of questions on the CHS(Cocoon, Hibernate, Spring) 
petstore project:

Nr.1:
I want to replace the HSQL with my MySQL database. What must I exactly 
change in the "applicationContext.xml" to do that.
Is this part still neccessary for my needs or does this only start and stop 
the hsql-database?

<bean id="hsqlServer" class="org.apache.cocoon.petstore.database.HsqlServer" 
init-method="start" destroy-method="stop"></bean>

I'm starting my MySQL-db "by hand".

Nr.2:
I want to use the proxool connection-pooling. So is this part (in the 
"applicationContext.xml") still neccessary for my needs?:

<bean id="myDataSource" class="org.apache.commons.dbcp.BasicDataSource" 
destroy-method="close" depends-on="hsqlServer">
	<property name="driverClassName">
		<value>com.mysql.jdbc.Driver</value>
	...
	<property name="password">
		<value/>
	</property>
</bean>

Or can I totally exchange it with something like this?:

<bean id="sessionFactory" 
class="org.springframework.orm.hibernate.LocalSessionFactoryBean">
		....
	<property name="hibernateProperties">
		<props>
			<prop 
key="hibernate.connection.driver_class">com.mysql.jdbc.Driver</prop>
			...
			<prop key="hibernate.c3po.min_size">5</prop>
			...
			<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
		</props>
	</property>
	<property name="dataSource">
		<ref bean="myDataSource"/>
	</property>
</bean>

I'm new to spring, so I don't know what the "myDataSource"-bean stands for. 
Where is it used in the further application?
And do I need something like the "myDataSource"-bean for my approach then?

Nr3:
I couldn't find the mapping-files, like Account.hbm.xml,etc? Are there any? 
Or better: Is there a database-model for the petstore in generell?
In UML, mapping-files or whatever?

Nr4:
Is there some generell documentation for this chs-project?

Thanks in advance
Jonny

_________________________________________________________________
Die rote Karte für lästige E-Mails. MSN Hotmail mit Junk-Mail-Filter. 
http://www.msn.de/antispam/prevention/junkmailfilter Jetzt kostenlos 
anmelden!


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


Re: Questions on CHS (Cocoon, Hibernate, Spring) petstore project

Posted by Mark Lowe <me...@gmail.com>.
using a hibernate.properties file will let you do what you want. Its
not the same as the deprecated use of hibernate.properties that you
read in the hibernate docs, you can configure properties easily in
spring to configure whatever you like. There are numerous examples of
this in spring documentation.

Mark

On Apr 11, 2005 11:25 AM, Jonny Becker <jo...@hotmail.com> wrote:
> Hi,
> 
> thanks for the quick response.
> But what does this tell me? It's your configuration and it gives me some
> more hints how I could confiure this?
> 
> But the questions aren't answerd and still remain.
> 
> This looks like there is hibernate configuration everywhere in your
> different files. Do I really need this mix? Can't I just somewhere refer to
> my hibernate.cfg.xml.
> 
> cheers
> Jonny
> 
> >From: Leszek Gawron <lg...@mobilebox.pl>
> >Reply-To: users@cocoon.apache.org
> >To: users@cocoon.apache.org
> >Subject: Re: Questions on CHS (Cocoon, Hibernate, Spring) petstore project
> >Date: Mon, 11 Apr 2005 10:59:27 +0200
> >
> >Jonny Pony wrote:
> >>Hi,
> >>
> >>I've got a couple of questions on the CHS(Cocoon, Hibernate, Spring)
> >>petstore project:
> >my config is:
> >
> >><?xml version="1.0" encoding="UTF-8"?>
> >><!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
> >>"http://www.springframework.org/dtd/spring-beans.dtd">
> >><beans>
> >>      <!-- 'system' beans -->
> >>      <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
> >>destroy-method="close">
> >>              <property name="driverClassName">
> >>                      <value>${db.driver}</value>
> >>              </property>
> >>              <property name="url">
> >>                      <value>${db.url}</value>
> >>              </property>
> >>              <property name="username">
> >>                      <value>${db.username}</value>
> >>              </property>
> >>              <property name="password">
> >>                      <value>${db.password}</value>
> >>              </property>
> >>      </bean>
> >>      <bean id="sessionFactory"
> >>class="org.springframework.orm.hibernate.LocalSessionFactoryBean">
> >>              <property name="configLocation">
> >>                      <value>classpath:hibernate.cfg.xml</value>
> >>              </property>
> >>              <property name="hibernateProperties">
> >>                      <props>
> >>                              <prop key="hibernate.dialect">${hibernate.dialect}</prop>
> >>                              <prop key="hibernate.show_sql">${hibernate.showsql}</prop>
> >>                      </props>
> >>              </property>
> >>              <property name="dataSource">
> >>                      <ref bean="dataSource"/>
> >>              </property>
> >>      </bean>
> >>      <bean id="transactionManager"
> >>class="org.springframework.orm.hibernate.HibernateTransactionManager">
> >>              <property name="sessionFactory">
> >>                      <ref bean="sessionFactory"/>
> >>              </property>
> >>      </bean>
> >>      <bean id="placeholderConfig"
> >>class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
> >>              <property
> >>name="location"><value>classpath:/spring.properties</value></property>
> >>      </bean>
> >>      <bean id="matchAllWithPropReq"
> >>class="org.springframework.transaction.interceptor.MatchAlwaysTransactionAttributeSource">
> >>              <property
> >>name="transactionAttribute"><value>PROPAGATION_REQUIRED</value></property>
> >>      </bean>
> >>      <bean id="matchAllTxInterceptor"
> >>class="org.springframework.transaction.interceptor.TransactionInterceptor">
> >>              <property name="transactionManager"><ref
> >>bean="transactionManager"/></property>
> >>              <property name="transactionAttributeSource"><ref
> >>bean="matchAllWithPropReq"/></property>
> >>      </bean>
> >>      <bean id="autoProxyCreator"
> >>class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">
> >>              <property name="interceptorNames">
> >>                      <list>
> >>                              <idref local="matchAllTxInterceptor"/>
> >>                      </list>
> >>              </property>
> >>              <property name="beanNames">
> >>                      <list>
> >>                              <value>*Service</value>
> >>                      </list>
> >>              </property>
> >>      </bean>         <!-- 'application beans' -->
> >></beans>
> >
> >and the hibernate.cfg.xml is:
> >><!DOCTYPE hibernate-configuration PUBLIC      "-//Hibernate/Hibernate
> >>Configuration DTD//EN"
> >>      "http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd">
> >><hibernate-configuration>
> >>      <session-factory>
> >>              <property name="query.substitutions">true 1, false 0, yes 'Y', no
> >>'N'</property>
> >>              <property name="jdbc.use_streams_for_binary">true</property>
> >>              <property name="max_fetch_depth">2</property>
> >>              <property
> >>name="cache.provider_class">net.sf.hibernate.cache.EhCacheProvider</property>
> >>
> >>              <mapping resource="com/hidden/Address.hbm.xml"/>
> >>      </session-factory>
> >></hibernate-configuration>
> >
> >spring.properties is:
> >>db.url=jdbc:mysql://localhost/dbname?characterEncoding=utf8
> >>db.username=root
> >>db.password=
> >>db.driver=com.mysql.jdbc.Driver
> >>hibernate.dialect=net.sf.hibernate.dialect.MySQLDialect
> >>hibernate.showsql=false
> >
> >
> >--
> >Leszek Gawron                                      lgawron@mobilebox.pl
> >IT Manager                                         MobileBox sp. z o.o.
> >+48 (61) 855 06 67                              http://www.mobilebox.pl
> >mobile: +48 (501) 720 812                       fax: +48 (61) 853 29 65
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> >For additional commands, e-mail: users-help@cocoon.apache.org
> >
> 
> _________________________________________________________________
> Machen Sie lästigen E-Mails ein Ende. MSN Hotmail mit Junk-Mail-Filter.
> http://www.msn.de/antispam/prevention/junkmailfilter Jetzt kostenlos
> anmelden!
> 
> ---------------------------------------------------------------------
> 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: Questions on CHS (Cocoon, Hibernate, Spring) petstore project

Posted by Jonny Becker <jo...@hotmail.com>.
Hi,

thanks for the quick response.
But what does this tell me? It's your configuration and it gives me some 
more hints how I could confiure this?

But the questions aren't answerd and still remain.

This looks like there is hibernate configuration everywhere in your 
different files. Do I really need this mix? Can't I just somewhere refer to 
my hibernate.cfg.xml.


cheers
Jonny


>From: Leszek Gawron <lg...@mobilebox.pl>
>Reply-To: users@cocoon.apache.org
>To: users@cocoon.apache.org
>Subject: Re: Questions on CHS (Cocoon, Hibernate, Spring) petstore project
>Date: Mon, 11 Apr 2005 10:59:27 +0200
>
>Jonny Pony wrote:
>>Hi,
>>
>>I've got a couple of questions on the CHS(Cocoon, Hibernate, Spring) 
>>petstore project:
>my config is:
>
>><?xml version="1.0" encoding="UTF-8"?>
>><!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" 
>>"http://www.springframework.org/dtd/spring-beans.dtd">
>><beans>
>>	<!-- 'system' beans -->
>>	<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" 
>>destroy-method="close">
>>		<property name="driverClassName">
>>			<value>${db.driver}</value>
>>		</property>
>>		<property name="url">
>>			<value>${db.url}</value>
>>		</property>
>>		<property name="username">
>>			<value>${db.username}</value>
>>		</property>
>>		<property name="password">
>>			<value>${db.password}</value>
>>		</property>
>>	</bean>
>>	<bean id="sessionFactory" 
>>class="org.springframework.orm.hibernate.LocalSessionFactoryBean">
>>		<property name="configLocation">
>>			<value>classpath:hibernate.cfg.xml</value>
>>		</property>
>>		<property name="hibernateProperties">
>>			<props>
>>				<prop key="hibernate.dialect">${hibernate.dialect}</prop>
>>				<prop key="hibernate.show_sql">${hibernate.showsql}</prop>
>>			</props>
>>		</property>
>>		<property name="dataSource">
>>			<ref bean="dataSource"/>
>>		</property>
>>	</bean>
>>	<bean id="transactionManager" 
>>class="org.springframework.orm.hibernate.HibernateTransactionManager">
>>		<property name="sessionFactory">
>>			<ref bean="sessionFactory"/>
>>		</property>
>>	</bean>
>>	<bean id="placeholderConfig" 
>>class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
>>		<property 
>>name="location"><value>classpath:/spring.properties</value></property>
>>	</bean>
>>	<bean id="matchAllWithPropReq" 
>>class="org.springframework.transaction.interceptor.MatchAlwaysTransactionAttributeSource">
>>		<property 
>>name="transactionAttribute"><value>PROPAGATION_REQUIRED</value></property>
>>	</bean>
>>	<bean id="matchAllTxInterceptor" 
>>class="org.springframework.transaction.interceptor.TransactionInterceptor">
>>		<property name="transactionManager"><ref 
>>bean="transactionManager"/></property>
>>		<property name="transactionAttributeSource"><ref 
>>bean="matchAllWithPropReq"/></property>
>>	</bean>
>>	<bean id="autoProxyCreator" 
>>class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">
>>		<property name="interceptorNames">
>>			<list>
>>				<idref local="matchAllTxInterceptor"/>
>>			</list>
>>		</property>
>>		<property name="beanNames">
>>			<list>
>>				<value>*Service</value>
>>			</list>
>>		</property>
>>	</bean>        	<!-- 'application beans' -->
>></beans>
>
>and the hibernate.cfg.xml is:
>><!DOCTYPE hibernate-configuration PUBLIC 	"-//Hibernate/Hibernate 
>>Configuration DTD//EN"
>>	"http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd">
>><hibernate-configuration>
>>	<session-factory>
>>		<property name="query.substitutions">true 1, false 0, yes 'Y', no 
>>'N'</property>
>>		<property name="jdbc.use_streams_for_binary">true</property>
>>		<property name="max_fetch_depth">2</property>
>>		<property 
>>name="cache.provider_class">net.sf.hibernate.cache.EhCacheProvider</property>
>>
>>		<mapping resource="com/hidden/Address.hbm.xml"/>
>>	</session-factory>
>></hibernate-configuration>
>
>spring.properties is:
>>db.url=jdbc:mysql://localhost/dbname?characterEncoding=utf8
>>db.username=root
>>db.password=
>>db.driver=com.mysql.jdbc.Driver
>>hibernate.dialect=net.sf.hibernate.dialect.MySQLDialect
>>hibernate.showsql=false
>
>
>--
>Leszek Gawron                                      lgawron@mobilebox.pl
>IT Manager                                         MobileBox sp. z o.o.
>+48 (61) 855 06 67                              http://www.mobilebox.pl
>mobile: +48 (501) 720 812                       fax: +48 (61) 853 29 65
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
>For additional commands, e-mail: users-help@cocoon.apache.org
>

_________________________________________________________________
Machen Sie lästigen E-Mails ein Ende. MSN Hotmail mit Junk-Mail-Filter. 
http://www.msn.de/antispam/prevention/junkmailfilter Jetzt kostenlos 
anmelden!


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


Re: Questions on CHS (Cocoon, Hibernate, Spring) petstore project

Posted by Leszek Gawron <lg...@mobilebox.pl>.
Jonny Pony wrote:
> Hi,
> 
> I've got a couple of questions on the CHS(Cocoon, Hibernate, Spring) 
> petstore project:
my config is:

> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
> <beans>
> 	<!-- 'system' beans -->
> 	<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
> 		<property name="driverClassName">
> 			<value>${db.driver}</value>
> 		</property>
> 		<property name="url">
> 			<value>${db.url}</value>
> 		</property>
> 		<property name="username">
> 			<value>${db.username}</value>
> 		</property>
> 		<property name="password">
> 			<value>${db.password}</value>
> 		</property>
> 	</bean>
> 	<bean id="sessionFactory" class="org.springframework.orm.hibernate.LocalSessionFactoryBean">
> 		<property name="configLocation">
> 			<value>classpath:hibernate.cfg.xml</value>
> 		</property>
> 		<property name="hibernateProperties">
> 			<props>
> 				<prop key="hibernate.dialect">${hibernate.dialect}</prop>
> 				<prop key="hibernate.show_sql">${hibernate.showsql}</prop>
> 			</props>
> 		</property>
> 		<property name="dataSource">
> 			<ref bean="dataSource"/>
> 		</property>
> 	</bean>
> 	<bean id="transactionManager" class="org.springframework.orm.hibernate.HibernateTransactionManager">
> 		<property name="sessionFactory">
> 			<ref bean="sessionFactory"/>
> 		</property>
> 	</bean>
> 	<bean id="placeholderConfig" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
> 		<property name="location"><value>classpath:/spring.properties</value></property>
> 	</bean>
> 	<bean id="matchAllWithPropReq" class="org.springframework.transaction.interceptor.MatchAlwaysTransactionAttributeSource">
> 		<property name="transactionAttribute"><value>PROPAGATION_REQUIRED</value></property>
> 	</bean>
> 	<bean id="matchAllTxInterceptor" class="org.springframework.transaction.interceptor.TransactionInterceptor">
> 		<property name="transactionManager"><ref bean="transactionManager"/></property>
> 		<property name="transactionAttributeSource"><ref bean="matchAllWithPropReq"/></property>
> 	</bean>
> 	<bean id="autoProxyCreator" class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">
> 		<property name="interceptorNames">
> 			<list>
> 				<idref local="matchAllTxInterceptor"/>
> 			</list>
> 		</property>
> 		<property name="beanNames">
> 			<list>
> 				<value>*Service</value>
> 			</list>
> 		</property>
> 	</bean>        
> 	<!-- 'application beans' -->
> </beans>

and the hibernate.cfg.xml is:
> <!DOCTYPE hibernate-configuration PUBLIC 
> 	"-//Hibernate/Hibernate Configuration DTD//EN"
> 	"http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd">
> <hibernate-configuration>
> 	<session-factory>
> 		<property name="query.substitutions">true 1, false 0, yes 'Y', no 'N'</property>
> 		<property name="jdbc.use_streams_for_binary">true</property>
> 		<property name="max_fetch_depth">2</property>
> 		<property name="cache.provider_class">net.sf.hibernate.cache.EhCacheProvider</property>
> 
> 		<mapping resource="com/hidden/Address.hbm.xml"/>
> 	</session-factory>
> </hibernate-configuration>

spring.properties is:
> db.url=jdbc:mysql://localhost/dbname?characterEncoding=utf8
> db.username=root
> db.password=
> db.driver=com.mysql.jdbc.Driver
> hibernate.dialect=net.sf.hibernate.dialect.MySQLDialect
> hibernate.showsql=false


-- 
Leszek Gawron                                      lgawron@mobilebox.pl
IT Manager                                         MobileBox sp. z o.o.
+48 (61) 855 06 67                              http://www.mobilebox.pl
mobile: +48 (501) 720 812                       fax: +48 (61) 853 29 65

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


Re: Questions on CHS (Cocoon, Hibernate, Spring) petstore project

Posted by Ugo Cei <ug...@apache.org>.
Il giorno 11/apr/05, alle 15:13, Jonny Becker ha scritto:

> Apache DBCP Pooling is used here. This is probably a dump question. 
> But why aren't there any configurations made? Is DBCP better than c3p0 
> (in this case)?

There aren't any configurations here because it's using the defaults. 
Any configuration parameter that has a setter method in the 
org.apache.commons.dbcp.BasicDataSource class can be set simply by 
adding a <property> child element.

>
>> Don't. Using Spring, you should define the (possibly pooled) 
>> datasource as its own bean, and refer to it in the sessionFactory 
>> bean definition. Spring will instantiate and wire them up in the 
>> correct order.
>
> Could you give me a small "code" hint, how this should look like. I'm 
> totally new to spring.

There's no code at all! This is the beauty of it. The class 
implementing the "sessionFactory" bean 
(org.springframework.orm.hibernate.LocalSessionFactoryBean) has a 
setDataSource method that will automatically be called with the correct 
value.

I think you should really get up to speed with Spring, by reading at 
least the first chapters of its manual. It shouldn't take you more than 
a few minutes, but you'll have a much easier time going forward with 
CHS, if you do.

	Ugo

-- 
Ugo Cei
Tech Blog: http://agylen.com/
Source.zone: http://sourcezone.info/
Wine & Food Blog: http://www.divinocibo.it/

Re: Questions on CHS (Cocoon, Hibernate, Spring) petstore project

Posted by Jonny Becker <jo...@hotmail.com>.
Hi,

thanks all for the answers.
I wanted to use c3p0 instead of Proxool. Got mixed up. Sorry.

>class="org.apache.commons.dbcp.BasicDataSource"

Apache DBCP Pooling is used here. This is probably a dump question. But why 
aren't there any configurations made? Is DBCP better than c3p0 (in this 
case)?


>Don't. Using Spring, you should define the (possibly pooled) datasource as 
>its own bean, and refer to it in the sessionFactory bean definition. Spring 
>will instantiate and wire them up in the correct order.

Could you give me a small "code" hint, how this should look like. I'm 
totally new to spring.

Thanks
Jonny




>From: Ugo Cei <ug...@apache.org>
>Reply-To: users@cocoon.apache.org
>To: users@cocoon.apache.org
>Subject: Re: Questions on CHS (Cocoon, Hibernate, Spring) petstore project
>Date: Mon, 11 Apr 2005 13:56:09 +0200
>
>Il giorno 11/apr/05, alle 10:40, Jonny Pony ha scritto:
>
>>I want to replace the HSQL with my MySQL database. What must I exactly 
>>change in the "applicationContext.xml" to do that.
>>Is this part still neccessary for my needs or does this only start and 
>>stop the hsql-database?
>>
>><bean id="hsqlServer" 
>>class="org.apache.cocoon.petstore.database.HsqlServer" init-method="start" 
>>destroy-method="stop"></bean>
>
>You can remove this, as it is needed only to start the embedded HSQL 
>server.
>
>>Nr.2:
>>I want to use the proxool connection-pooling. So is this part (in the 
>>"applicationContext.xml") still neccessary for my needs?:
>>
>><bean id="myDataSource" class="org.apache.commons.dbcp.BasicDataSource" 
>>destroy-method="close" depends-on="hsqlServer">
>>	<property name="driverClassName">
>>		<value>com.mysql.jdbc.Driver</value>
>>	...
>>	<property name="password">
>>		<value/>
>>	</property>
>></bean>
>
>If Proxool implements java.sql.DataSource, you can simply change the name 
>of the implementing class. Also, remove depends-on="hsqlServer".
>
>>
>>Or can I totally exchange it with something like this?:
>>
>><bean id="sessionFactory" 
>>class="org.springframework.orm.hibernate.LocalSessionFactoryBean">
>>		....
>>	<property name="hibernateProperties">
>>		<props>
>>			<prop 
>>key="hibernate.connection.driver_class">com.mysql.jdbc.Driver</prop>
>>			...
>>			<prop key="hibernate.c3po.min_size">5</prop>
>>			...
>>			<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
>>		</props>
>>	</property>
>>	<property name="dataSource">
>>		<ref bean="myDataSource"/>
>>	</property>
>></bean>
>
>Don't. Using Spring, you should define the (possibly pooled) datasource as 
>its own bean, and refer to it in the sessionFactory bean definition. Spring 
>will instantiate and wire them up in the correct order.
>
>>And do I need something like the "myDataSource"-bean for my approach then?
>
>Yes.
>>
>>I couldn't find the mapping-files, like Account.hbm.xml,etc? Are there 
>>any? Or better: Is there a database-model for the petstore in generell?
>>In UML, mapping-files or whatever?
>
>The mapping files are automatically generated by the build.xml script, 
>using XDoclet. Look for @hibernate tags in comments. Try running "ant 
>genmappings".
>
>>
>>Is there some generell documentation for this chs-project?
>
>Nothing besides what you can read on the website.
>
>	Ugo
>
>--
>Ugo Cei
>Tech Blog: http://agylen.com/
>Source.zone: http://sourcezone.info/
>Wine & Food Blog: http://www.divinocibo.it/
><< smime.p7s >>

_________________________________________________________________
MSN Hotmail. Anmelden und gewinnen! http://www.msn.de/email/webbased/ Ihre 
Chance, eines von 10 T-Mobile MDA II zu gewinnen!


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


Re: Questions on CHS (Cocoon, Hibernate, Spring) petstore project

Posted by Ugo Cei <ug...@apache.org>.
Il giorno 11/apr/05, alle 10:40, Jonny Pony ha scritto:

> I want to replace the HSQL with my MySQL database. What must I exactly 
> change in the "applicationContext.xml" to do that.
> Is this part still neccessary for my needs or does this only start and 
> stop the hsql-database?
>
> <bean id="hsqlServer" 
> class="org.apache.cocoon.petstore.database.HsqlServer" 
> init-method="start" destroy-method="stop"></bean>

You can remove this, as it is needed only to start the embedded HSQL 
server.

> Nr.2:
> I want to use the proxool connection-pooling. So is this part (in the 
> "applicationContext.xml") still neccessary for my needs?:
>
> <bean id="myDataSource" 
> class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close" 
> depends-on="hsqlServer">
> 	<property name="driverClassName">
> 		<value>com.mysql.jdbc.Driver</value>
> 	...
> 	<property name="password">
> 		<value/>
> 	</property>
> </bean>

If Proxool implements java.sql.DataSource, you can simply change the 
name of the implementing class. Also, remove depends-on="hsqlServer".

>
> Or can I totally exchange it with something like this?:
>
> <bean id="sessionFactory" 
> class="org.springframework.orm.hibernate.LocalSessionFactoryBean">
> 		....
> 	<property name="hibernateProperties">
> 		<props>
> 			<prop 
> key="hibernate.connection.driver_class">com.mysql.jdbc.Driver</prop>
> 			...
> 			<prop key="hibernate.c3po.min_size">5</prop>
> 			...
> 			<prop 
> key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
> 		</props>
> 	</property>
> 	<property name="dataSource">
> 		<ref bean="myDataSource"/>
> 	</property>
> </bean>

Don't. Using Spring, you should define the (possibly pooled) datasource 
as its own bean, and refer to it in the sessionFactory bean definition. 
Spring will instantiate and wire them up in the correct order.

> And do I need something like the "myDataSource"-bean for my approach 
> then?

Yes.
>
> I couldn't find the mapping-files, like Account.hbm.xml,etc? Are there 
> any? Or better: Is there a database-model for the petstore in 
> generell?
> In UML, mapping-files or whatever?

The mapping files are automatically generated by the build.xml script, 
using XDoclet. Look for @hibernate tags in comments. Try running "ant 
genmappings".

>
> Is there some generell documentation for this chs-project?

Nothing besides what you can read on the website.

	Ugo

-- 
Ugo Cei
Tech Blog: http://agylen.com/
Source.zone: http://sourcezone.info/
Wine & Food Blog: http://www.divinocibo.it/