select t1.columnFK from table1 t1, table2 t2 where t1.columnFK=t1.columnpk AND t2.somecolumn='value1'
select t2.columnPK from table2 t2 where t2.somecolumn='value2'
So I have to update all the values from first select statement with the values of second one.
I tried writing update query like this:
UPDATE table1
SET table1.columnFK = table2.columnPK
From tabel1 t1, table2 t2
Where t1.columnfk=t2.columnpk AND somevalue='value2'
Here is the relationship
table2.columnpk is referenced as table1.coulmnfk.
table1.hbm.xml
<many-to-one
name="table2"
column=""coulmnfk""
class="table2class"
cascade="none"/>
Table 2 relation goes like this:
<set name="table1" table=""table1"" inverse="true" cascade="none">
<key column=""coulmnFK""/>
<one-to-many class="table1"/>
</set>
Not sure how would I include first condition.
I stil find your referential integrity a bit odd to accept. Usually child table fk is updated with parent pk.
Here is the logic you may need to use, assuming you cureently have parent pk as a fk in your child talble and you are trying to add child pk as a fk into parent table…using a
join