openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jody Grassel (Commented) (JIRA)" <>
Subject [jira] [Commented] (OPENJPA-2166) the column for @id is named id no matter the field name or @column
Date Thu, 29 Mar 2012 21:13:29 GMT


Jody Grassel commented on OPENJPA-2166:

I experimented with the above example, and confirmed that indeed it does use "id" instead
of "name":

2548  TestPU  TRACE  [main] openjpa.jdbc.SQL - <t 2057079871, conn 292826622> executing
stmnt 534000652 CREATE TABLE TestEntity (id BIGINT NOT NULL, -- datastore id
    intVal INTEGER, PRIMARY KEY (id))

However, the JPA 2 Specification (Section 2.1 "The Entity Class", page 21) states: "The entity
class must not be final.  No methods or persistent instance variables of the entity class
may be final."  In your example, you have the final keyword in getName().  Removing it produced
the following:

2577  TestPU  TRACE  [main] openjpa.jdbc.SQL - <t 225005258, conn 2098993638> executing
stmnt 1083655680 CREATE TABLE TestEntity (name VARCHAR(255) NOT NULL, intVal INTEGER, PRIMARY
KEY (name))

Which is the correct behavior (and my test was then able to persist/fetch the entity).  That
said, this is still not a proper way for OpenJPA to behave.
> the column for @id is named id no matter the field name or @column
> ------------------------------------------------------------------
>                 Key: OPENJPA-2166
>                 URL:
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: sql
>    Affects Versions: 2.2.0
>         Environment: ubuntu 64bits, java 1.7.0_01
>            Reporter: santiago garcĂ­a pimentel
>            Priority: Minor
>              Labels: mapping
> I have an entity with an Id:
> @Entity
> @Table(name = "Domain")
> public class Domain implements, Comparable<Domain> {
> ...
> @Id
> 	@Column(name = "name", unique = true, nullable = false)
> 	public final String getName() {
> 		return;
> 	}
> ...
> still openjpa seems to be querying for a column id instead of name

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:!default.jspa
For more information on JIRA, see:


View raw message