openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Fay Wang <fyw...@yahoo.com>
Subject Re: Passing Current Timestamp to Entity Object's Timestamp field variable
Date Mon, 28 Jun 2010 21:41:46 GMT
Hi,
   You can create a table with a column type Timestamp NOT NULL WITH DEFAUTLT. DB2 will automatically
set the value of CURRENT TIMESTAMP to it when a sql of 
INSERT INTO SALES.INVOICE (id, description) VALUES (?, ?) [params=(int) 1, (null) null]
is executed. The following is an example:

@Entity
@Table(name = "INVOICE", schema = "SALES")
public class Invoice implements Serializable {

  @Id
   private int id;

   private String description;

   @Column(columnDefinition="Timestamp NOT NULL WITH DEFAULT", insertable= false, updatable=false)
    private java.sql.Timestamp ts;







----- Original Message ----
From: Arnav-A <arnav216@gmail.com>
To: dev@openjpa.apache.org
Sent: Mon, June 28, 2010 1:52:25 PM
Subject: Passing Current Timestamp to Entity Object's Timestamp field variable


Hi All
    I have to insert one Invoice Object to the DB2 Table. I have
insertTimestamp field in the Invoice Entity Class. I want a value that needs
to be set to this variable so that it insert the current timestamp value of
the DB2 Database system i.e. generated insert query should have CURRENT
TIMESTAMP as value for the column corresponding to the insertTimestamp field
variable.
  
-- 
View this message in context: http://openjpa.208410.n2.nabble.com/Passing-Current-Timestamp-to-Entity-Object-s-Timestamp-field-variable-tp5232583p5232583.html
Sent from the OpenJPA Developers mailing list archive at Nabble.com.



      


Mime
View raw message