Tags: Toplink Essentials, JPA, virtual columns
Hi All,
This appears to be a newbie question. But I cannot get it solved.
First, my system is Eclipse + TOPlink essentials.
My relational db table has a computed column. It is derived from a column of the same table.
create table WINE(
WINE_NAME VARCHAR2(25),
WINE_STORAGE_DATE DATE,
VINTAGE AS (EXTRACT(YEAR FROM WINE_STORAGE_DATE))
);
In my JAVA entity, I would like to map VINTAGE into a "auto-generated" field. In this way, when I update relational db table, VINTAGE won't be in the JPA generated INSERT statement, but I can query the VINTAGE into my java entity/object.
I tried the following JPA annotation in my java entity class.
@Entity
public class Wine implements Serializable {
@GeneratedValue private Integer VINTAGE;
}
I can query db table -- VINTAGE flows from db table to my java object. But when I update table ( I left VINTAGE un-specified ), I get the following error:
Internal Exception: java.sql.SQLException: ORA-54013: INSERT operation disallowed on virtual columns
Error Code: 54013
Call: INSERT INTO WINE(WINE_NAME, WINE_STORAGE_DATE, VINTAGE) VALUES (?, ?, ?)
bind => PinotNoir, 2003-01-05 00:00:00.0, null
Any suggestions on what annotation tage I should use to tell the JPA Provider not to include VINTAGE in the auto-generated INSERT statement?
Thank you very much.
WineCraz
[Message sent by forum member 'winecraz' (jngwu_at_yahoo.com)]
http://forums.java.net/jive/thread.jspa?messageID=365782