Created
February 22, 2015 11:43
-
-
Save jhoryna/d59157ef74c3eaa2056f to your computer and use it in GitHub Desktop.
Database view with no notion of primary key as @entity using EclipseLink 2.5.x, JPA 2.0
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: | |
Exception [EclipseLink-6044] (Eclipse Persistence Services - 2.5.1. ..... | |
org.eclipse.persistence.exceptions.QueryException Exception Description: The primary key read from the row [row omitted here] during the execution of the query was detected to be null. Primary keys must not contain null. | |
Questions: | |
- What do I make wrong? | |
- Is it a problem that I define EclipseLink as JPA provider in persistence.xml file BUT using EclipseLink extensions, e.g. @PrimaryKey. Is this ignored? | |
- How persistence.xml should look like in generall? | |
Thanks for the answers. | |
Jan |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment