users@glassfish.java.net

JPA queries and properties

From: <glassfish_at_javadesktop.org>
Date: Tue, 27 May 2008 11:03:30 PDT

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:
[code]select x.id, x.displayName from Foo x[/code]

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

[code] @Id
  @Basic(fetch=FetchType.EAGER, optional=false)
  @GeneratedValue(strategy=GenerationType.IDENTITY)
  @Column(name="FooID", nullable=false, updatable=false, scale=0)
  protected long getID() {
    return this.id;
  }

  protected void setID(final long id) {
    this.id = id;
  }[/code]

I rewrote the query to be:
[code]select x.ID, x.displayName from Foo x[/code]

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

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
[Message sent by forum member 'ljnelson' (ljnelson)]

http://forums.java.net/jive/thread.jspa?messageID=276831