You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Jens Skripczynski <sk...@myrealbox.com> on 2004/06/20 17:05:48 UTC

[OT] EJB QL: using findBy with a legacy class

Hi,

I have a Problem using find with a serializeable CMP field.
(and hope someone here can give me a hint).
-------------------
I'm using J2EE 1.3.1 Sun RI and ran into this problem:

I have a serializeable class as a CMP Field (Permission) and 
want to Do a findByPermission EJB query. (example code below).

Things I have checked:
- The dependant class in Serializeable (EJB SPEC 2.0 10.3.3)
  and has a new 'equals' method
- find Parameter is of the same class as CMP field as required for the
  = operator (SPEC 2.0 11.2.10)

--------- EJB QL Statement ------------
SELECT OBJECT(perm) FROM PermissionSchema as perm
WHERE perm.permission = ?1
--------- EJB QL Statement ------------

But still the RI Deployment Tool complains (while generating SQL):
----
Invalid type of expression (perm.permission = ?1)
----

Any Ideas ??



----------- Java example code -----------
public abstract class PermissionBean implements EntityBean{

   public abstract void setPermission(Permission perm);
   public abstract Permission getPermission();

   [...]
}

public interface PermissionHomeLocal extends EJBLocalHome {

   [...]

   public PermissionLocal findByPermission(Permission permission) 
      throws FinderException;

}

public class Permission implements Serializable {
   public final static Permission CREATE_USER = new Permission("Create User", "Allows User Creation");

   final private String name;
   final private String description;


   private Permission (final String name, final String description){
      this.name = name;
      this.description = description;
   }

   public String getName() { return this.name; }

   public String getDescription() { return this.description; }

   public boolean equals(Object obj) {
      if (obj instanceof Permission) {
         Permission perm = (Permission) obj;
         return this.name.equals(perm.getName());
      } 
      return false;
   }
}
----------- Java example code -----------

Ciao

Jens Skripczynski
-- 
E-Mail: skripi-lists(at)myrealbox(dot)com

"They say if you play the Windows 2000 CD backward, you can hear satanic words."
"Oh, that�s nothing. If you play it forward it installs Windows 2000 ...."


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org