Skip to main content

JPA queries and properties

1 reply [Last post]
ljnelson
Offline
Joined: 2003-08-04

Perhaps this is simple pilot error and this is addressed somewhere in the specification, but I thought I'd put it out there.

I got burned by defining a query like this:
select x.id, x.displayName from Foo x

...where Foo had an ID property defined like this:

  @Id<br />
  @Basic(fetch=FetchType.EAGER, optional=false)<br />
  @GeneratedValue(strategy=GenerationType.IDENTITY)<br />
  @Column(name="FooID", nullable=false, updatable=false, scale=0)<br />
  protected long getID() {<br />
    return this.id;<br />
  }</p>
<p>  protected void setID(final long id) {<br />
    this.id = id;<br />
  }

I rewrote the query to be:
select x.ID, x.displayName from Foo x

...and that didn't work either. The only one that worked was:
select x.iD, x.displayName from Foo x

Shouldn't the property introspection mechanism in JPA--which is not JavaBeans compliant, but is certainly inspired by JavaBeans--do the same sort of decapitalization behavior as Beans.decapitalize()? Is this a Toplink bug, or a feature?

Thanks,
Laird

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
chris_delahunt
Offline
Joined: 2005-07-06

Hello,

Looks like a bug. But 234222 has been filed for the issue in EclipseLink (https://bugs.eclipse.org/bugs/show_bug.cgi?id=234222) if you want to reference it or add anything that I might have missed. EclipseLink will be the RI for JPA2.0 and will be the default JPA provider in glassfish going forward.

Best regards,
Chris