my current query is as below and it works fine for single user:
ao.find(da.class, Query.select().where("user=?",user)
Now, i want to change this query to fetch multi users data as below , but it did not work and giving me invalid column name.
ao.find(da.class, Query.select().where("user IN (?)",user)
Also, tried by applying single qutoes. Even single user come in param value then also not worked and giving same error.
can any one suggest me whats wrong and have to correct here ?
error shows as below:
Caused by: java.sql.SQLException: Column not found: user in statement [SELECT * FROM PUBLIC.AO_0371A8_da WHERE "user" IN (?)] at org.hsqldb.jdbc.Util.throwError(Unknown Source) at org.hsqldb.jdbc.jdbcPreparedStatement.<init>(Unknown Source) at org.hsqldb.jdbc.jdbcConnection.prepareStatement(Unknown Source) at org.apache.tomcat.dbcp.dbcp.DelegatingConnection.prep
OR //when used "('?')" and verified for single user
at java.lang.Thread.run(Thread.java:662) Caused by: java.sql.SQLException: Column not found: user in statement [SELECT * FROM PUBLIC.AO_0371A8_da WHERE "user" IN ('?')] at org.hsqldb.jdbc.Util.throwError(Unknown Source) at org.hsqldb.jdbc.jdbcPreparedStatement.<init>(Unknown Source) at org.hsqldb.jdbc.jdbcConnection.prepareStatement(Unknown Source) at org.apache.tomcat.dbcp.dbcp.DelegatingConnection.prepareStatement(DelegatingConnection.java:262) .....
Thank You
Community moderators have prevented the ability to post new answers.
If you want to use IN queries, you need to construct the placeholder list yourself. Here is a snippet taken from: https://ecosystem.atlassian.net/browse/AO-263?focusedCommentId=69495&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-69495
MyEntity[] findEntities(Iterable<String> matchValues) { String placeholderCommaList = Joiner.on(", ").join(Iterables.transform(matchValues, Functions.constant("?"))); Object[] matchValuesArray = Iterables.toArray(matchValues, Object.class); return ao.find(MyEntity.class, "primary_key_field_name", Query.select().where("match_field_name IN (" + placeholderCommaList + ")", matchValuesArray)); }
It's important, that the number of placeholders ("?") matches the number of arguments.
Hope this helps
Hi,
Did you use Postgres database? Because, in this case, the user word is reserved for this database. If you want, you can apply the query on pgAdmin or something else and the result will be the same.
Regards.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Updated original comment above.
ok, we can do through OR ..
it will be easy if i could use "IN" keyword...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.