users@glassfish.java.net

Re: EJBQL Question

From: <glassfish_at_javadesktop.org>
Date: Tue, 08 May 2007 12:11:34 PDT

Hi,

> I tried that already,
>
> I still get "unknown state or association field
> [asString] of class [sample.entity.Value]"
>
> Doesnt 'field' means variable of the class and not
> the method?

The error message uses the term state field, because the JPA uses the term state field for a persistent field or property. This depends on whether the entity class uses field based or property based access type. Where do you place your annotations such as @Id or @Basic: on the field or on the getter? Please note, a single access type applies to an hierarchy of entity classes, defined by the root entity class (sample.entity.Value in your case).

The query compiler tries to find a persistent field called asString or a persistent property asString meaning a getter method getAsString in class Value depending on whether Value has a field or property based access type. In your sample code the getter getAsString was annotated as @Transient, so it is not persistent property and cannot be used in a query.

I hope this helps.

Regards Michael
[Message sent by forum member 'mb124283' (mb124283)]

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