Ask the Expert

Is it possible to send an array as an argument to the finder?

I want to create a finder method which sends an array or more than one value to the finder method. The finder method will return Collection. Is it possible to send an array as an argument to the finder?

One workaround, I thought, is to send the comma-separated string and put that string into IN operator using EJBQL. But the problem is => My table has a field whose datatype is number. It gives me invalid number error. Please help me to overcome this problem.

    Requires Free Membership to View

The answer to the question concerning passing an array as an argument to the finder method is, yes, and here is why.

javax.ejb.EJBHome and javax.ejb.EJBObject both extend java.rmi.Remote. This implies that they must adhere to the Java RMI specification. RMI requires that parameters and return types be primitive types, objects that implement or objects that implement java.rmi.Remote. Since the client/server interaction with a finder method is a remote operation, the parameters and return type of the finder method must be serializable.

Serializable objects are objects that implement the interface as a declaration that they have the ability to be read from or written to a stream. An array is a reference type that implements the interface. Thus, an array is serializable and therefore eligible to be the parameter of a finder method. However, for an array to be completely serializable, its components must also be serializable.

This was first published in September 2002

There are Comments. Add yours.

TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to: