Date being stripped of time on commitChanges()

From: Williams, Beth (beth.william..FIB.ORG)
Date: Thu Mar 10 2005 - 12:23:22 EST

  • Next message: Andrus Adamchik: "Re: Date being stripped of time on commitChanges()"

    I have a object entity (Notes) for which I am trying to insert a new Notes object (see code sample below). As you can see, the noteDate attribute is being set with a Date object of today's date which includes the time (2005-03-10 11:10:36.32). The problem is that when I do the commitChanges() the record is inserted into the table, however the time is stripped from the Date object (2005-03-10 00:00:00). Do I need to specify it a type other than Date in the Modeler? If so, what should that type be? If not, any thoughts on what might be happening? I have included code sample along with data mappings for the entity. Any help would be much appreciated. Thanks.

    Code sample:
    Notes newNote = (Notes) cayenneContext.createAndRegisterNewObject(Notes.class);
    newNote.setText(noteText);
    newNote.setNoteDate(new Date());
    newNote.setNotesType("FLD");

    ctxt.commitChanges();

    **********************

    DB Entity mapping:
            <db-entity name="NOTES" schema="MEMBERSHIP">
                    <db-attribute name="DE_WE_DT" type="DATE" length="7"/>
                    <db-attribute name="DT_ACCESSED" type="DATE" length="7"/>
                    <db-attribute name="GRP" type="VARCHAR" length="10"/>
                    <db-attribute name="LEAD_ID" type="INTEGER" length="9"/>
                    <db-attribute name="MEM_ID" type="INTEGER" length="9"/>
                    <db-attribute name="NMO_GEN_NBR" type="INTEGER" length="9"/>
                    <db-attribute name="NOTES_SEQ_NBR" type="INTEGER" isPrimaryKey="true" isMandatory="true" length="9"/>
                    <db-attribute name="NOTES_TYPE" type="VARCHAR" length="10"/>
                    <db-attribute name="NOTE_DT" type="DATE" isMandatory="true" length="7"/>
                    <db-attribute name="PERSON_ID" type="INTEGER" length="9"/>
                    <db-attribute name="PROSP_ID" type="INTEGER" length="9"/>
                    <db-attribute name="RPT_WE_DT" type="DATE" length="7"/>
                    <db-attribute name="SALE_SEQ_NBR" type="INTEGER" length="9"/>
                    <db-attribute name="TEXT" type="LONGVARCHAR" isMandatory="true"/>
                    <db-attribute name="USER_ACCESSED" type="VARCHAR" length="30"/>
                    <db-key-generator>
                            <db-generator-type>ORACLE</db-generator-type>
                            <db-generator-name>NOTES_SEQ_NBR</db-generator-name>
                            <db-key-cache-size>20</db-key-cache-size>
                    </db-key-generator>
            </db-entity>

    **********************

    Object Entity Mapping:
            <obj-entity name="Notes" className="org.nfib.core.model.Notes" dbEntityName="NOTES">
                    <obj-attribute name="dataEntryWeekEndindDate" type="java.util.Date" db-attribute-path="DE_WE_DT"/>
                    <obj-attribute name="dateAccessed" type="java.util.Date" db-attribute-path="DT_ACCESSED"/>
                    <obj-attribute name="group" type="java.lang.String" db-attribute-path="GRP"/>
                    <obj-attribute name="leadId" type="java.lang.Integer" db-attribute-path="LEAD_ID"/>
                    <obj-attribute name="memberId" type="java.lang.Integer" db-attribute-path="MEM_ID"/>
                    <obj-attribute name="nonMemberOrganizationNumber" type="java.lang.Integer" db-attribute-path="NMO_GEN_NBR"/>
                    <obj-attribute name="noteDate" type="java.util.Date" db-attribute-path="NOTE_DT"/>
                    <obj-attribute name="notesType" type="java.lang.String" db-attribute-path="NOTES_TYPE"/>
                    <obj-attribute name="personId" type="java.lang.Integer" db-attribute-path="PERSON_ID"/>
                    <obj-attribute name="prospectId" type="java.lang.Integer" db-attribute-path="PROSP_ID"/>
                    <obj-attribute name="reportWeekEndingDate" type="java.util.Date" db-attribute-path="RPT_WE_DT"/>
                    <obj-attribute name="saleSequenceNumber" type="java.lang.Integer" db-attribute-path="SALE_SEQ_NBR"/>
                    <obj-attribute name="text" type="java.lang.String" db-attribute-path="TEXT"/>
                    <obj-attribute name="userAccessed" type="java.lang.String" db-attribute-path="USER_ACCESSED"/>
            </obj-entity>



    This archive was generated by hypermail 2.0.0 : Thu Mar 10 2005 - 12:23:24 EST