There is an exception, when I input chinese.
Exception in thread "main" java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
at java.util.ArrayList.RangeCheck(ArrayList.java:547)
at java.util.ArrayList.get(ArrayList.java:322)
at Test.main(Test.java:29)
public static void main(String args[]) throws Exception {
String sqlStatement = "select * from User where username like '%晓霞s%'";
Query q = new Query();
q.parse(sqlStatement);
List myFiles = new ArrayList<User>();
User user1 = new User();
user1.setPassword("pwd1");
user1.setUsername("周典");
User user2 = new User();
user2.setPassword("pwd2");
user2.setUsername("周晓霞");
myFiles.add(user1);
myFiles.add(user2);
QueryResults results = q.execute(myFiles);
List<User> users = results.getResults();
for (int i = 0; i < users.size(); i++) {
User user = users.get(i);
System.out.println(user.getPassword());
System.out.println(user.getUsername());
}
}
public class User {
private String username;
private String password;
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
}
The bug is commited by me. To my surprise, It will not exist when I run the program several times.
Hi Zhou,
I can't actually reproduce this, I ran the code you provided and it works ok for me.
You'll notice that the exception occurs in your "main" method rather than in the JoSQL code. I couldn't check line 29 because of course I don't have the full code and the screenshot you gave only goes up to line 25.
If you can let me have a reproducible test case then I can have another look.
Gary