Bug 123 : Support for @Column insertable=false, updateable=false
Priority 
High
Reported Version 
 
Logged By 
Rob
Status 
Fixed
Fixed Version 
2.0.0
Assigned To 
 
Product 
Ebean - core
Duplicate Of 
 
Created 
11/06/2009
Updated 
11/06/2009
Type 
Bug
 
Attachments 
No attachments

Dose the Ebean partially support the JPA ?
eg.
The Annotation @Column(javax.persistence.Column) has a property insertable.
The feature is necessary.

create table test (
id int primary key AUTO_INCREMENT,
inserttime Timestamp default CURRENT_TIMESTAMP,
insertvalue varchar(20)
)

When inserting new row into the table test, you just need set the value of insertvalue, and the id and inserttime have had the defualt value.
so
@Column(name="issuetime",insertable=false)
private Timestamp inserttime ;
is more flexible.

 
Rob 11 Jun 11:29
Notes about @InsertedTimestamp

Yes this is a bug in Ebean 1.2

Yes, your example will work. The issue with that approach for supporting the "inserted timestamp" is that the Entity is then out of synch with the values in the database.

This means its is not updateable without excluding the inserttime property from updates as well (which you want to do in this case) - but your entity is still out of synch. This is a similar issue to having a DB trigger changing the data... you entity is now out of synch with the values in the database and you have to re-query to get back in synch (assuming you want to use that entity afterwards or expect it to be in sych).

This is the reason I'd prefer to use the "generated property" approach. Still, I better log and fix this bug so people can do a similar approach to the one you suggest.

Cheers, Rob.

Rob 11 Jun 11:31
Fixed

I have fixed this. Pretty easy as I already had a dbWrite flag, and split it into dbInsertable and dbUpdatable.

Fixed the code. Not in HEAD yet though.

woResponse

Upload a file