Hi all,
I have an CayenneDataObject UniquePlace that has an attribute: java.sql.Date datecreated
In the MySQL 4.0 database, the corresponding column is: DATECREATED of type date
I'm using Cayenne 1.1.0rc1 and I tried Cayenne 1.0.5 and got the same results, which is that the datecreated
attribute is NULL before it gets committed to the database. The problem is that the field is not allowed to be NULL
in the database.
The code I'm using to set this up is as follows:
UniquePlace uniquePlace = new UniquePlace();
ctxt.registerNewObject(uniquePlace);
..
..
java.util.Date aDate = new java.util.Date();
long dateLong = aDate.getTime();
java.sql.Date sqlDate = new java.sql.Date(dateLong);
uniquePlace.setDatecreated(sqlDate);
ctxt.setTransactionEventsEnabled(true);
ctxt.commitChanges(Level.WARN);
Here is the declaration for my uniqueplace entity:
<db-entity name="uniqueplace">
<db-attribute name="containernameid" type="INTEGER" isMandatory="true"/>
<db-attribute name="countrycodeid" type="INTEGER" isMandatory="true"/>
<db-attribute name="datecreated" type="DATE" isMandatory="true"/>
<db-attribute name="featurelocationid" type="INTEGER" isMandatory="true"/>
<db-attribute name="nametype" type="VARCHAR" isMandatory="true" length="65"/>
<db-attribute name="placenameid" type="INTEGER" isMandatory="true"/>
<db-attribute name="uniqueplaceid" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
</db-entity>
Thanks,
Robert Gottlieb
robert.gottlie..avy.mil
This archive was generated by hypermail 2.0.0 : Mon Jan 12 2004 - 13:51:30 EST