Hi,
Thanks for your reply. I tried several more things, still not working...
Here is the mapping files and code I used.
table1 mapping
-----------------
<class
name="com.tietronix.hibernateTest.dal.Table1"
table="Table1"
>
<id
name="table1pk"
type="java.lang.Integer"
column="table1pk"
unsaved-value="0"
>
<generator class="identity" />
</id>
<property
name="table1desc"
type="java.lang.String"
column="table1desc"
length="10"
/>
<!-- Associations -->
<!-- bi-directional one-to-many association to Table2 -->
<set
name="table2s"
lazy="true"
inverse="true"
cascade="all"
>
<key>
<column name="table1pk" />
</key>
<one-to-many
class="com.tietronix.hibernateTest.dal.Table2"
/>
</set>
</class>
table2 mapping
-----------------
<class
name="com.tietronix.hibernateTest.dal.Table2"
table="Table2"
>
<id
name="table2pk"
type="java.lang.Integer"
column="table2pk"
unsaved-value="0"
>
<generator class="identity" />
</id>
<property
name="table2desc"
type="java.lang.String"
column="table2desc"
length="10"
/>
<!-- Associations -->
<!-- bi-directional many-to-one association to Table1 -->
<many-to-one
name="table1"
class="com.tietronix.hibernateTest.dal.Table1"
not-null="true"
cascade="save-update"
>
<column name="table1pk" />
</many-to-one>
</class>
code that im running
------------------------
org.hibernate.Session session2 = HibernateUtil.currentSession();
Transaction tx = session2.beginTransaction();
Table2 tbl2_1 = new Table2();
tbl2_1.setTable2desc("GOOGLE");
Set mySet = new HashSet();
mySet.add(tbl2_1);
Table1 tbl1_1 = new Table1();
tbl1_1.setTable1desc("MSN");
tbl1_1.setTable2s(mySet);
session2.save(tbl1_1);
tx.commit();
HibernateUtil.closeSession();
error message that comes up
----------------------------------
22:10:56,471 ERROR [JDBCExceptionReporter] Cannot insert the value NULL into column 'table1pk', table 'hibernateTest.dbo.Table2'; column does not allow nulls. INSERT fails.
22:10:56,502 ERROR [Engine] StandardWrapperValve[
jsp]: Servlet.service() for
servlet jsp threw exception
org.hibernate.exception.ConstraintViolationException: could not insert: [com.tietronix.hibernateTest.dal.Table2]
Please help.
Lilly