Problem solve Get help with specific problems with your technologies, process and projects.

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.

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 java.io.Serializable 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 java.io.Serializable 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 java.io.Serializable 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.

Dig Deeper on Topics Archive

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.