Hi Robert,

Robert Einsle wrote:
Hy List,

We have an Database-Table with an default-Column (now()), and want to save data in it. How can i configure OJB to insert Data in this table to use the Database-Funktion to create the Data of this field?

The Table is created like this:

--- cut ---
CREATE TABLE import_log (
 log_tst TIMESTAMP NOT NULL DEFAULT now(),
 log_importer VARCHAR(64),

 PRIMARY KEY (log_tst)
);
--- cut ---

normaly i can Insert Data into the Table like

--- cut ---
INSERT INTO import_log (log_importer) VALUES ('re');
--- cut ---

can i let OJB do the same?


You could try two options (or use a combination of both):

1. If you don't need a ImportLog object on java-level, simply execute the sql-insert statement by your own.
http://db.apache.org/ojb/docu/guides/connection.html#Can+I+directly+obtain+a

2. If you handle with ImportLog objects, create a "normal" metadata mapping for ImportLog and set 'access' to read only.

<class-descriptor....

<object-cache class="org.apache.ojb.broker.cache.ObjectCacheEmptyImpl"/>

<field-descriptor
   name="logTimestamp"
   column="lod_tst"
   jdbc-type="TIMESTAMP"
   primarykey="true"
   autoincrement="false"
   access="readonly"
/>
....
</class-descriptor>

Additionally you can prevent OJB from caching these objects using a noop cache. Problems: After insert the ImportLog object, 'logTimestamp' field will still be 'null' (only set on DB level) and you can't perform a fast getObjectByIdentity(...) call to lookup the object from DB, because logTimestamp is the PK field too (workaround: introduce a separate autoincrement PK field and disable PK for logTimestamp).

regards,
Armin

Thanks for Help

best Greetings,

\Robert

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to