You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by Vo...@t-systems.com on 2003/12/04 14:01:04 UTC
INSERT with empty fields OJB / MySQL
Hello,
I'm running ojb v. 1.0.rc4-src.
I have a domain object containing some java.sql.Timestamp attributes that might be empty. When I insert them into the datbase via ojb, the empty date-attribues are filled with the current date. I have logged the insert statement with p6spy it looks like this:
INSERT INTO T (ID,C_ID,RECEPTION_DATE) VALUES ('123','76','')
The mysql-db changes '' to the current date.
My repository-xml looks like this:
class-descriptor class="com.yyy.T" table="T">
<field-descriptor name="id" primarykey="true" nullable="false" column="ID" jdbc-type="VARCHAR"/>
<field-descriptor name="cId" column="C_ID" jdbc-type="VARCHAR"/>
<field-descriptor name="receptionDate" column="RECEPTION_DATE" jdbc-type="TIMESTAMP"/>
</class-descriptor>
My table in the database looks like this
+-----------------+---------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-----------------+---------------+------+-----+---------+-------+
| T_ID | varchar(22) | | PRI | | |
| C_ID | varchar(22) | YES | | NULL | |
| RECEPTION_DATE | timestamp(14) | YES | | NULL | |
Is there a possibilty to configure ojb to use null instead of '' or even to write insert statements that only contain the attributes that are != null?
Or any other workaround?
Thank you
Volker Konrad
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org