users@glassfish.java.net

EJBQL Question

From: <glassfish_at_javadesktop.org>
Date: Mon, 07 May 2007 07:19:23 PDT

I was wondering,
I have some entities inherited from one parent,
It looks like:

@Entity @DiscriminatorValue("STR")
class ValueString extends Value {
private String value;
..
..
..
@Transient
public String getAsString() {
  return value;

}

@Entity @DiscriminatorValue("INT")
public Class ValueInt extends Value {
private Integer value;
...
...
@Transient
public String getAsString() {
  return value.toString();
}
}

public Class Value {

@Transient
public abstract String getAsString();
}




I was wondering if I could build a query with conditions based on the abstract method such as:

"select object(value) from Value value where value.asString like :param"


For this, I get in deployment time:
"unknown state or association field [asString] of class [sample.entity.Value]"


This is true, it's not a field but a method, but otherwise, I can't see any way to access the value of subclass (which named differently on each subclass) over parent.


Thanks,

Asaf.
[Message sent by forum member 'trouby' (trouby)]

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