Re: [Issue] Invoking Ebean.delete(Class<?> beanType, Collection<?> ids) throws NumberFormatException

102 views
Skip to first unread message

edge

unread,
Nov 10, 2012, 2:34:51 AM11/10/12
to eb...@googlegroups.com
use the EbeanServer method

public void delete(Class<?> beanType, Collection<?> ids);

instead


On Saturday, November 10, 2012 4:03:12 AM UTC+1, Wendy Sanarwanto wrote:
Hello All,

I'd like to report my finding when trying to delete a single record through calling Ebean.delete(Class<?> beanType, Collection<?> ids). The ids parameter contains an id refers to an existing record (e.g. ids = { 7 }) and the id's type is Long. When my app invokes the method using this parameter, a NumberFormatException is thrown and the delete operation fail.

Below is the snippet of the model:

@Entity
@Table(name="employee")
public class Employee implements Serializable {
    @Column(name="id")
    @Id
    public Long id;

    @NotEmpty
    @Column(name="first_name")
    public String firstName;

    @Column(name="last_name")
    public String lastName;
}

And below is the code snippet of the repository class that exposes the delete method:

public class EmployeeRepository {

    public int Delete(Long[ ] ids){
        return Ebean.delete(Employee.class, ids);
    }

// Other methods...
}

And the exception's message when the Repository's Delete method is invoked and takes 1 id on its parameter (e.g. ids = { 7 }):
             java.lang.NumberFormatException: For input string: "[Ljava.lang.Long;@5d63c3f0"

Exception does not happen when i use other Ebean's method to delete the record ( delete(Class<?> beanType, Object id) ) and the delete operation is success. Could you suggest me how to delete multiple records through calling a single delete method on Ebean when the record id's data type is Long ? Many thanks in advance.

Cheers.

Rob Bygrave

unread,
Nov 11, 2012, 5:58:05 PM11/11/12
to eb...@googlegroups.com
FYI

>> [delete by id] and the delete operation is success

With Delete by Id Ebean automatically converts the type of the Id (e.g. String to Long etc) if required.  It doesn't do this when you delete with a collection of Ids.



Cheers, Rob.
Reply all
Reply to author
Forward
0 new messages