cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From beyaNet Consultancy <beya...@ntlworld.com>
Subject Exception in Hibernate:problem parsing configuration/test/hibernate.cfg.xml
Date Wed, 21 Jan 2004 20:29:17 GMT
Hi,
I am getting the above message when I try and run hibernate from 
cocoon. Can anyone tell me what I am doing incorrectly?

1. class snippet:

public void add(){
         try {
             Configuration cfg = new Configuration()
             .configure ("/test/hibernate.cfg.xml");
             SessionFactory sf = cfg.buildSessionFactory();
             Session session = sf.openSession();
			Transaction transaction = session.beginTransaction();
			
			User usr = new User();
			usr.setID("143");
			usr.setUserName("x");
			usr.setPassword("x");
			usr.setEmailAddress("test@hotmail.com");
			usr.setLastLogon(newDate);
			
             session.save(usr);
			session.flush();
			transaction.commit();
		
             session.close();
             session = null;

             sf.close();
             sf = null;

             cfg = null;
			
         }
         catch ( Exception e) {
             state = "Exception in Hibernate: " + e.getMessage();
         }

2. hibernate.cfg.xml

<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 2.0//EN"

"http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd";>


<hibernate-configuration>

     <session-factory>
         <property 
name="connection.driver_class">org.postgresql.Driver</property>
		<property 
name="connection.url">jdbc:postgresql://localhost:5432/test</property>
		<property name="connection.username">x</property>
		<property name="connection.password">x</property>
		<property name="show_sql">false</property>
         <property name="use_outer_join">true</property>
         <property 
name="dialect">net.sf.hibernate.dialect.PostgreSQLDialect</property>

         <mapping resource="User2.hbm.xml"/>


     </session-factory>

</hibernate-configuration>

3. Users2.hbm.xml

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
    "-//Hibernate/Hibernate Mapping DTD 2.1//EN"
    "http://hibernate.sourceforge.net/hibernate-2.1.dtd">

<hibernate-mapping>
	<class name="test.User" table="users">
		<id name="ID" type="string" unsaved-value="null">
			<column name="LogonID" sql-type="char(32)" not-null="true"/>
             <generator class="uuid.hex"/>
		</id>
		
		<property name="userName" column="Name" type="string"/>
		<property name="password" column="Password" type="string"/>
		<property name="emailAddress" column="EmailAddress" type="string"/>
		<property name="lastLogon" column="Lastlogon" type="date"/>
	</class>
</hibernate-mapping>

Andrew
Mime
View raw message