openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jason Hanna" <>
Subject Re: [jira] Updated: (OPENJPA-765) Check for insertable or updateable before checking value for null
Date Wed, 17 Dec 2008 17:49:22 GMT
Hi All,

What's the recommended workaround for this scenario? I recently
started upgrading an application that uses time stamps in the manner
described by this issue (default value 'now()' set on the db). I think
this is a pretty common use case for a lot of web apps. Previously I
was using OpenJPA 0.9.7 and since upgrading to 1.2.0 my unit tests are
failing when persisting new objects. I can't seem to find an
acceptable combination of parameters using v1.2.0 that allows me to
keep attribute insertDatetime "read-only" while not resulting in a
org.apache.openjpa.persistence.ArgumentException during

---java getter/setter

	@Column(name="insert_datetime", nullable=false, insertable=false,
	public java.util.Date getInsertDatetime() {
		return insertDatetime;
	public void setInsertDatetime(java.util.Date insertDatetime) {
		this.insertDatetime = insertDatetime;

---db ddl

CREATE TABLE green.category
  id bigserial NOT NULL,
  "version" integer NOT NULL DEFAULT 0,
  insert_datetime timestamp with time zone NOT NULL DEFAULT now(),
  source character varying(50) NOT NULL,
  "name" character varying(100) NOT NULL,
  image_path character varying(100),


On Tue, Nov 11, 2008 at 11:42 AM, Michael Dick (JIRA) <> wrote:
>     [
> Michael Dick updated OPENJPA-765:
> ---------------------------------
>    Fix Version/s:     (was: 1.2.0)
>> Check for insertable or updateable before checking value for null
>> -----------------------------------------------------------------
>>                 Key: OPENJPA-765
>>                 URL:
>>             Project: OpenJPA
>>          Issue Type: Sub-task
>>    Affects Versions: 1.2.0, 1.2.1, 1.3.0, 2.0.0
>>            Reporter: Michael Dick
>>            Assignee: Michael Dick
>>             Fix For: 1.2.1, 1.3.0, 2.0.0
>> The fix for OPENJPA-665 exposed another issue with checking for null. If the entity
contains a "read-only" attribute (insertable=false, updatable=false) should we also check
whether the value is null?
>> A practical use case for this is a Date attribute which is automatically generated
by the database, ie
>> @Column(insertable=false, updatable=false, nullable=false, columnDefinition="LAST_UPD
>> private Date lastUpdated;
>> Before the fix for OPENJPA-665 such an attribute would not be checked for null.
> --
> This message is automatically generated by JIRA.
> -
> You can reply to this email to add a comment to the issue online.

View raw message