hi guys
I was doing a small example on hibernate, but i am stuck.
From my DAOImplimentation class i am calling Hibernate and i just want to do a simple insert using an sql statement.
This is my DaoImplimentation class where i have the query
public class TestDaoImpl implements TestDao
{
public TestReturnVO getInfo(
String ssn) throws DaoException;
public TestReturnVO insertInfo(TestVO testVO)
{
System.out.println("Inside Insert ssn");
TestReturnVO trVO = null;
//Call hibernate here.
Session session = HibernateUtil.getSessionFactory().getCurrentSession();
session.beginTransaction();
// Beginning of SQL
test, its db2 database
SQLQuery sqlQuery = session.createSQLQuery("insert into JAY.GENERALINFO('rani','london','3125552956', '1980-01-09','11')");
session.getTransaction().commit();
System.out.println("Inserted info record done");
return trVO;
}
}
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
This is my hibernate.cfg.xml file
<hibernate-configuration>
<session-factory>
<!-- Database connection settings -->
<property name="connection.datasource">frameworkAppDb</property>
<property name="show_sql">false</property>
<property name="dialect">org.hibernate.dialect.DB2390Dialect</property>
<property name="current_session_context_class">
thread</property>
<mapping resource="spResourceMapping/TestVO.hbm.xml"/>
</session-factory>
</hibernate-configuration>
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
and this is TestVO.hbm.xml file
<hibernate-mapping>
<class name="com.aoc.judiciary.framework.ValueObjects.TestVO">
<property name="name" column="1"/>
<property name="city" column="2"/>
<property name="ssn" column="3"/>
<property name="dob" column="4"/>
<property name="userId" column="5"/>
</class>
</hibernate-mapping>
++++++++++++++++++++++++++++++++++++++++++++++++++++++++
and this is the error i get
++++++++++++++++++++++++++++++++++++++++++++++
[5/14/07 2:05:06:557 GMT] 00000034 Configuration I Reading mappings from resource: spResourceMapping/TestVO.hbm.xml
[5/14/07 2:05:06:589 GMT] 00000034 XMLHelper E Error parsing XML: XML InputStream(17) The content of element type "class" must match "(meta*,subselect?,cache?,synchronize*,comment?,tuplizer*,
(id|composite-id),discriminator?,natural-id?,(version|timestamp)?,(property|many-to-one|one-to-one|component|dynamic-component|properties|any|map|set|list|bag|idbag|array|primitive-array)*,
((join*,subclass*)|joined-subclass*|union-subclass*),loader?,sql-insert?,sql-update?,sql-delete?,filter*,resultset*,(query|sql-query)*)".
++++++++++++++++++++++++++++++++++++++++++++++
am i missing something?
Also, "userId" (column=5, in TestVO.hbm.xml) is the primary key i have in the database. so Do i have to define it as primary key in my TestVO.hbm.xml file or is it optional?
any solutions greatly appreciated,
thanks very much
Jay