Skip to content

Instantly share code, notes, and snippets.

@jhoryna
jhoryna / gist:d59157ef74c3eaa2056f
Created Feb 22, 2015
Database view with no notion of primary key as @entity using EclipseLink 2.5.x, JPA 2.0
View gist:d59157ef74c3eaa2056f
Hi Adam,
We read data from a database view. This view has no database-side notion of primary key, but the columns (MyView.a, MyView.b, MyView.c) uniquelly identify a record. The columns MyView.a and MyView.b can contain NULL values.
My Java entity class looks like this:
@Entity
@PrimaryKey(validation=IdValidation.NONE, columns={@column(name="a"), @column(name="b", @column(name="c")})
public class MyView implements Serializable ......
If I run the query (as JUnit test) then I will receive the following error message:
You can’t perform that action at this time.