You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by beyaNet Consultancy <be...@ntlworld.com> on 2004/01/20 04:18:12 UTC

Cocoon -Hibernate problems part 2

hi,
as a follow on to the first email, I am adding here some further 
information as to the installation procedure I followed:

1. copied xalan.jar, xercesImpl.jar, xml-apis.jar to 
TOMCAT_HOME/common/endorsed

2. created the following users table to my test database:

CREATE TABLE "users" (
     "LogonID" character varying(20) NOT NULL DEFAULT 0,
     "Name" character varying(40),
     "Password" character varying(20),
     "EmailAddress" character varying(40),
     "Lastlogon" date,
     CONSTRAINT "logkey" PRIMARY KEY ("LogonID")
) WITH OIDS;

3. User.class to TOMCAT_HOME/webapps/cocoon/WEB-INF/classes/test

4. copied User.hbm.xml to 
TOMCAT_HOME/webapps/cocoon/WEB-INF/classes/test:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
    "-//Hibernate/Hibernate Mapping DTD//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping.dtd">

<hibernate-mapping>
	<class name="test.Userss" table="users">

		<id name="ID" column="LogonId" type="string">
			<generator class="assigned"/>
		</id>
		<property name="userName" column="Name" type="string"/>
		<property name="password" type="string"/>
		<property name="emailAddress" type="string"/>
		<property name="lastLogon" type="date"/>
	</class>
</hibernate-mapping>

5. copied hibernate.properties to 
TOMCAT_HOME/webapps/cocoon/WEB-INF/classes:

hibernate.dialect=net.sf.hibernate.dialect.PostgreSQLDialect
hibernate.connection.driver_class=org.postgresql.Driver
hibernate.connection.url=jdbc:postgresql://localhost:5432/test
hibernate.connection.username=root
hibernate.connection.password=m013644825
hibernate.query.substitutions='Y'
hibernate.connection.pool_size=5

6. copied hibernate2.jar odmg.jar, j2ee.jar, jcs.jar, jdom.jar, 
junit.jar, connector.jar, commons-pool.jar, commons-dbcp.jar, 
commons-beanutils.jar, dom4j.jar, cglib.jar, c3p0.jar to 
TOMCAT_HOME/webapps/cocoon/WEB-INF/lib

7. http://localhost:8080/cocoon/userhomes/test
username is written to the screen, but no data is written to the 
database. what is going on here? what have I missed?

Andrew

Re: Cocoon -Hibernate problems part 2

Posted by Ugo Cei <u....@cbim.it>.
beyaNet Consultancy wrote:
> Ugo,
> yes this is a typo and is not featured in my production code. Basically 
> this the first time I am using Hibernate. I saw, what I thought was a, 
> straight forward example just to see how things hang together in 
> hibernate. Apparently I have been told the I am not doing the following:
> '...committing or even using any transaction.'???

I don't think you explicitly need to commit a transaction. Typos aside, 
your code looks fine to me and certainly it does not seem to be a Cocoon 
problem. You should see if you can recreate the problem with a 
standalone class rather than an XSP page and post your question to the 
Hibernate forum.

It would also be wise to follow the advice of Hugo Burm and take a look 
at your logs.

	Ugo


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


Re: Cocoon -Hibernate problems part 2

Posted by beyaNet Consultancy <be...@ntlworld.com>.
Ugo,
yes this is a typo and is not featured in my production code. Basically 
this the first time I am using Hibernate. I saw, what I thought was a, 
straight forward example just to see how things hang together in 
hibernate. Apparently I have been told the I am not doing the 
following:
  '...committing or even using any transaction.'???

Andrew

On 20 Jan 2004, at 08:31, Ugo Cei wrote:

> beyaNet Consultancy wrote:
>> hi,
>> as a follow on to the first email, I am adding here some further 
>> information as to the installation procedure I followed:
> ...
>> <class name="test.Userss" table="users">
>
> "Userss"? Is this a typo?
>
> 	Ugo
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>

Re: Cocoon -Hibernate problems part 2

Posted by beyaNet Consultancy <be...@ntlworld.com>.
further to my original posts, the source of the material i used was  
from a tutorial situated at :
http://wiki.cocoondev.org/Wiki.jsp? 
page=UsingHibernateToMakeYourJavaBeansPersistent

If anyone has the time, could you take a look at this for me and see  
whether you get the same results. As stated before, I manage to pull  
information from the class but nothing is being written to my  
postgresql table.

thanks in advance


Andrew
On 20 Jan 2004, at 08:31, Ugo Cei wrote:

> beyaNet Consultancy wrote:
>> hi,
>> as a follow on to the first email, I am adding here some further  
>> information as to the installation procedure I followed:
> ...
>> <class name="test.Userss" table="users">
>
> "Userss"? Is this a typo?
>
> 	Ugo
>
>
> ---------------------------------------------------------------------
> 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: Cocoon -Hibernate problems part 2

Posted by Ugo Cei <u....@cbim.it>.
beyaNet Consultancy wrote:
> hi,
> as a follow on to the first email, I am adding here some further 
> information as to the installation procedure I followed:
...
> <class name="test.Userss" table="users">

"Userss"? Is this a typo?

	Ugo


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


RE: Cocoon -Hibernate problems part 2

Posted by Hugo Burm <hu...@xs4all.nl>.
Hello

1) I assume Userss is a typo: <class name="test.Userss" table="users">, your
class appears to be test.User.
2 Check that the dtd
"http://hibernate.sourceforge.net/hibernate-mapping.dtd"> is for the
Hibernate version you are using (this one is for 1.x ?)
2) Turn on debugging in Hibernate and verify that it:
    a) Can open your database connection
    b) Understands your mapping (hbm) file
    c) Check for cfg,hs,sf not being null in your add function in Class
User. But I suppose you checked that the error message in the exception in
this function is not printed.
    d) BTW, I do not know whether this should work; an instance of a class
saving itself.
In my case Hibernate gives a lot of debugging info in the Tomcat console.
You cannot develop without that.

Regards

Hugo Burm


-----Original Message-----
From: beyaNet Consultancy [mailto:beyanet@ntlworld.com]
Sent: Tuesday, January 20, 2004 4:18 AM
To: users@cocoon.apache.org
Subject: Cocoon -Hibernate problems part 2


hi,
as a follow on to the first email, I am adding here some further information
as to the installation procedure I followed:

1. copied xalan.jar, xercesImpl.jar, xml-apis.jar to
TOMCAT_HOME/common/endorsed

2. created the following users table to my test database:

CREATE TABLE "users" (
"LogonID" character varying(20) NOT NULL DEFAULT 0,
"Name" character varying(40),
"Password" character varying(20),
"EmailAddress" character varying(40),
"Lastlogon" date,
CONSTRAINT "logkey" PRIMARY KEY ("LogonID")
) WITH OIDS;

3. User.class to TOMCAT_HOME/webapps/cocoon/WEB-INF/classes/test

4. copied User.hbm.xml to TOMCAT_HOME/webapps/cocoon/WEB-INF/classes/test:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping.dtd">

<hibernate-mapping>
<class name="test.Userss" table="users">

<id name="ID" column="LogonId" type="string">
<generator class="assigned"/>
</id>
<property name="userName" column="Name" type="string"/>
<property name="password" type="string"/>
<property name="emailAddress" type="string"/>
<property name="lastLogon" type="date"/>
</class>
</hibernate-mapping>

5. copied hibernate.properties to
TOMCAT_HOME/webapps/cocoon/WEB-INF/classes:

hibernate.dialect=net.sf.hibernate.dialect.PostgreSQLDialect
hibernate.connection.driver_class=org.postgresql.Driver
hibernate.connection.url=jdbc:postgresql://localhost:5432/test
hibernate.connection.username=root
hibernate.connection.password=m013644825
hibernate.query.substitutions='Y'
hibernate.connection.pool_size=5

6. copied hibernate2.jar odmg.jar, j2ee.jar, jcs.jar, jdom.jar, junit.jar,
connector.jar, commons-pool.jar, commons-dbcp.jar, commons-beanutils.jar,
dom4j.jar, cglib.jar, c3p0.jar to TOMCAT_HOME/webapps/cocoon/WEB-INF/lib

7. http://localhost:8080/cocoon/userhomes/test
username is written to the screen, but no data is written to the database.
what is going on here? what have I missed?

Andrew


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