I work on a Oracle 9.2 database.
It accept the null value , because when I test it with a DBUnit, this work fine.
Here is my mapping
Quote:
<hibernate-mapping package="model">
<class name="Mt940" table="MT940">
<id name="idMt940" column="ID_MT940" type="java.lang.Long">
<generator class="increment"/>
</id>
<property name="mt940F20Sender" column="MT940_F20_SENDER" type="java.lang.String" />
<property name="mt940F21ReferenceMessage" column="MT940_F21_REFERENCE_MESSAGE" type="java.lang.String" />
<property name="mt940F25AccountId" column="MT940_F25_ACCOUNT_ID" type="java.lang.String" />
<property name="mt940F28cSequenceNumber" column="MT940_F28C_SEQUENCE_NUMBER" type="java.lang.String" />
<property name="mt940F28cStatementNumber" column="MT940_F28C_STATEMENT_NUMBER" type="java.lang.String" />
<property name="mt940F60Amount" column="MT940_F60_AMOUNT" type="java.lang.Float" />
<property name="mt940F60DcMark" column="MT940_F60_DC_MARK" type="java.lang.String" />
<property name="mt940F60OperationDate" column="MT940_F60_OPERATION_DATE" type="java.util.Date" />
<property name="mt940F60Option" column="MT940_F60_OPTION" type="java.lang.String" />
<property name="mt940F62Amount" column="MT940_F62_AMOUNT" type="java.lang.Float" />
<property name="mt940F62DcMark" column="MT940_F62_DC_MARK" type="java.lang.String" />
<property name="mt940F62OperationDate" column="MT940_F62_OPERATION_DATE" type="java.util.Date" />
<property name="mt940F62Option" column="MT940_F62_OPTION" type="java.lang.String" />
<property name="mt940F64Amount" column="MT940_F64_AMOUNT" type="java.lang.Float" />
<property name="mt940F64DcMark" column="MT940_F64_DC_MARK" type="java.lang.String" />
<property name="mt940F64OperationDate" column="MT940_F64_OPERATION_DATE" type="java.util.Date" />
<many-to-one name="account" column="ID_ACCOUNT" class="Account" not-null="true" />
<many-to-one name="currency" column="MT940_F60_CURRENCY_ID" class="Currency" not-null="true" />
<many-to-one name="currency1" column="MT940_F62_CURRENCY_ID" class="Currency" not-null="true" />
<many-to-one name="currency2" column="MT940_F64_CURRENCY_ID" class="Currency" not-null="false" />
<many-to-one name="mt940Brut" column="ID_MT940_BRUT" class="Mt940Brut" not-null="true" />
<set name="mt940ForwardBalanceSet" inverse="true">
<key column="ID_MT940"/>
<one-to-many class="Mt940ForwardBalance"/>
</set>
<set name="mt940TransactionSet" inverse="true">
<key column="ID_MT940"/>
<one-to-many class="Mt940Transaction"/>
</set>
</class>
The currency mapping is
Quote:
<hibernate-mapping package="model">
<class name="Currency" table="CURRENCY">
<id name="idCurrency" column="ID_CURRENCY" type="java.lang.Long">
<generator class="increment"/>
</id>
<property name="currencyName" column="CURRENCY_NAME" type="java.lang.String" />
<set name="accountSet" inverse="true">
<key column="ID_CURRENCY"/>
<one-to-many class="Account"/>
</set>
<set name="mt940Set" inverse="true">
<key column="MT940_F62_CURRENCY_ID"/>
<one-to-many class="Mt940"/>
</set>
<set name="mt9401Set" inverse="true">
<key column="MT940_F60_CURRENCY_ID"/>
<one-to-many class="Mt940"/>
</set>
<set name="mt9402Set" inverse="true">
<key column="MT940_F64_CURRENCY_ID"/>
<one-to-many class="Mt940"/>
</set>
<set name="mt940ForwardBalanceSet" inverse="true">
<key column="FORWARD_BALANCE_CURRENCY_ID"/>
<one-to-many class="Mt940ForwardBalance"/>
</set>
</class>
</hibernate-mapping>
In my code a just made something like that :
Code:
mt.setMt940F20Sender(m.getF20());
mt.setMt940F21ReferenceMessage(m.getF21());
mt.setMt940F28cSequenceNumber(m.getF28_sequence());
mt.setMt940F28cStatementNumber(m.getF28_statement());
mt940Hib.saveMt940(mt);
And Hibernate retuns :
Code:
[java] org.springframework.orm.hibernate3.HibernateSystemException: not-null property references a null or transient value: com.planaxis.swifter.model.Mt940.currency2; nested exception is org.hibernate.PropertyValueException: not-null property references a null or transient value: com.planaxis.swifter.model.Mt940.currency2
[java] org.hibernate.PropertyValueException: not-null property references a null or transient value: com.planaxis.swifter.model.Mt940.currency2
[java] at org.hibernate.engine.Nullability.checkNullability(Nullability.java:72)
[java] at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:236)
[java] at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:160)
[java] at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:108)
[java] at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:184)
[java] at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:173)
[java] at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:96)
[java] at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:69)
[java] at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:468)
[java] at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:463)
[java] at org.springframework.orm.hibernate3.HibernateTemplate$18.doInHibernate(HibernateTemplate.java:630)
[java] at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:315)
[java] at org.springframework.orm.hibernate3.HibernateTemplate.saveOrUpdate(HibernateTemplate.java:627)
[java] at com.planaxis.swifter.dao.hibernate.Mt940DAOHibernate.saveMt940(Unknown Source)
[java] at com.planaxis.swifter.front.Main.launch(Unknown Source)
[java] at com.planaxis.swifter.front.Main.listCreated(Unknown Source)