what is the difference between session.saveorupdate() and sesssion.save(). when to use saveorupdate ? I tried to insert a row with saveOrUpdate but it gave me Could not synchronize database state with session , SQL insert, update or delete failed (row not found) error.
when i changed it to session.save() it worked.
can someone tell the difference ?
here is my hbm.xml file
<class
name="*****Rule"
table="vlid_rules"
>
<id
name="ruleKey"
type="java.math.BigDecimal"
column="RULE_KEY"
>
<generator class="assigned" />
</id>
<property
name="ruleName"
type="java.lang.String"
column="RULE_NAME"
not-null="true"
unique="true"
length="64"
/>
<property
name="ruleSetName"
type="java.lang.String"
column="RULE_SET_NAME"
not-null="true"
unique="true"
length="64"
/>
<property
name="ruleType"
type="java.lang.String"
column="RULE_TYPE"
length="32"
/>
<property
name="ruleDescription"
type="java.lang.String"
column="RULE_DESCRIPTION"
length="65535"
/>
<property
name="className"
type="java.lang.String"
column="CLASS_NAME"
length="64"
/>
<property
name="methodName"
type="java.lang.String"
column="METHOD_NAME"
length="64"
/>
<property
name="errorMessage"
type="java.lang.String"
column="ERROR_MESSAGE"
length="65535"
/>
<property
name="document"
type="java.lang.String"
column="DOCUMENT"
length="65535"
/>
<property
name="negate"
type="java.lang.Boolean"
column="NEGATE"
length="1"
/>
<property
name="failIfNull"
type="java.lang.Boolean"
column="FAIL_IF_NULL"
length="1"
/>
<property
name="stopIfFail"
type="java.lang.Boolean"
column="STOP_IF_FAIL"
length="1"
/>
<property
name="continueIfNull"
type="java.lang.Boolean"
column="CONTINUE_IF_NULL"
length="1"
/>
<property
name="global"
type="java.lang.Boolean"
column="GLOBAL"
length="1"
/>
<!-- Associations -->
<!-- bi-directional one-to-many association to RuleAttribute -->
<set
name="attributes"
lazy="true"
inverse="true"
cascade="none"
>
<key>
<column name="RULE_KEY" />
</key>
<one-to-many
class="*******RuleAttribute"
/>
</set>
</class>
|