Skip to Main Content

Integration

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Toplink Essentials: how can I not to auto persist computed/virtual column

724526Sep 25 2009 — edited Sep 28 2009
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.

Jing

Edited by: user11935396 on Sep 25, 2009 1:36 PM

Edited by: user11935396 on Sep 25, 2009 1:37 PM
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 26 2009
Added on Sep 25 2009
2 comments
1,684 views