I have the following error when trying to create this table
java.lang.IllegalArgumentException: Error: at (1, 1140) missing ')' at
',', at line 1:1140
"create table if not exists " + TABLE_NAME +
"(id string, " +
"subId string, " +
"startTime timestamp(4), " +
"timeId string, " +
"primary key(id, shard(subId, startTime)))";
Any ideas in how to solve this
The error message is not clear but your issue is because the shard(...) should be the first thing after primary key (, and , id should come after the shard key.
"create table if not exists " + TABLE_NAME +
"(id string, " +
"subId string, " +
"startTime timestamp(4), " +
"timeId string, " +
"primary key(shard(subId, startTime), id))";
Related
Getting ERROR: java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near emp.employeeMangement.api.DTO.ResponseDTO(emp.empName,emp.gender,emp.email,emp at line 1
#Query(value = "select NEW com.emp.employeeMangement.api.DTO.ResponseDTO(" +
`"emp.empName," +
"emp.gender," +
"emp.email," +
"emp.empCode," +
"att.noOfAbsent," +
"att.noOfPresent," +
"att.month," +
"att.noOfDaysInMonth," +
"sal.salAmount," +
"round(#per_day\\:=sal.salAmount/att.noOfDaysInMonth) as salperday," +
"round(att.noOfPresent*#per_day) as Salarycurrentmonth " +
") " +
"from Employee as emp " +
"join Attendence as att " +
"on emp.emp_id=att.cp_fk" +
" left join Salary as sal " +
"on sal.emp_id_fk=emp.emp_id",nativeQuery = true)
List<ResponseDTO> getInfoInExcel();
I have this query:
#Query(value =
"select distinct t from TimesheetReport t "
+ "where t.month = :month and t.year = :year and t.approvedByMaster = false "
+ "and (:#{#rule.employee} is null or :#{#rule.employee.id} is null "
+ "or t.account.id = :#{#rule.employee.id}) "
+ "and t.id in "
+ "(select distinct dt.timesheetReport.id from DailyTime dt "
+ "where (:#{#rule.project} is null or :#{#rule.project.id} is null "
+ "or dt.project.id = :#{#rule.project.id}) "
+ "and (:#{#rule.client} is null or :#{#rule.client.id} is null "
+ "or dt.client.id = :#{#rule.client.id})) "
+ "or t.id in "
+ "(select distinct cdt.timesheetReport.id from CustomDailyTime cdt "
+ "where (:#{#rule.project} is null or :#{#rule.project.id} is null "
+ "or cdt.project.id = :#{#rule.project.id}) "
+ "and (:#{#rule.client} is null or :#{#rule.client.id} is null "
+ "or cdt.client.id = :#{#rule.client.id}) "
+ ")"
)
Set<TimesheetReport> findTimesheetsMatchingManualApprovalRule(LeaderManualApprovalRulesDTO rule, int month, int year);
I know this is caused by employee object being null.
This happens despite first checking if employee in rule is null and then checking if employee object id field is null. I still get "Property or field 'id' cannot be found on null".
Is it because SpEL needs to be able to evalute every parameter before firing a query?
This is the query:
" select dbo from EmpWorkDiaryEntriesDBO dbo"
+ "lef join fetch dbo.empWorkDiaryEntriesDetailsDBOSet dbos"
+ "where dbo.recordStatus='A' and dbo.erpWorkEntryDate between (:startDate)
and (:endDate) order by erpWorkEntryDate ASC ";
And this is the error
getting eror expecting EOF, found ')'
#Query(value = "SELECT DISTINCT * " +
"FROM chores WHERE id in (SELECT a.id " +
"FROM chores as a INNER JOIN chores_assign_users as b ON a.id=b.chore_id " +
"WHERE (a.is_deleted=FALSE " +
"AND a.family_id=:familyId " +
"AND (:userId IS NULL OR (cast(b.user_id as VARCHAR) IN :userId)) " +
"AND (:status IS NULL OR (a.status IN :status)) " +
"AND (:title IS NULL OR a.title LIKE cast(:title as text)) " +
"AND (:from IS NULL OR :to IS NULL OR cast(created_at as VARCHAR) >= :from AND cast(created_at as VARCHAR) <= :to)) " +
"ORDER BY :sortByDeadline" +
", CASE WHEN :sortByDeadline THEN a.deadline END DESC " +
", CASE WHEN NOT :sortByDeadline THEN a.created_at END DESC)",
countQuery = "SELECT COUNT(DISTINCT a.id) FROM chores as a INNER JOIN chores_assign_users as b ON a.id=b.chore_id " +
"WHERE a.is_deleted=FALSE " +
"AND a.family_id=:familyId " +
"AND (:userId IS NULL OR (cast(b.user_id as VARCHAR) IN (:userId))) " +
"AND (:status IS NULL OR (a.status IN (:status))) " +
"AND (:title IS NULL OR a.title LIKE cast(:title as text))" +
"AND (:from IS NULL OR :to IS NULL OR cast(created_at as VARCHAR) >= :from AND cast(created_at as VARCHAR) <= :to)) ",
nativeQuery = true)
ArrayList<Chore> findAlLFilteredByUserAndStatusAndTitleSortedByCreatedAtOrDeadLine(#Param("familyId") int familyId,
#Param("userId") List<String> userId,
#Param("status") List<String> status,
#Param("title") String title,
#Param("sortByDeadline") boolean sortByDeadline,
#Param("from") String from,
#Param("to") String to,
Pageable pageable);
I have this native query in a jpa repository. As you can see, I search for the records which have user_id IN :userId. This works fine as long as userId contains only one element. But if userId contains more than one element, this exception will be thrown org.postgresql.util.PSQLException: ERROR: argument of AND must be type boolean, not type record. The same problem happens to "AND (:status IS NULL OR (a.status IN :status)) "
user_id has type integer
status has type varchar
I am having a hard time finding a way to fix this. Could you please help me with this? And also, is it good to pass a List of integers to the query as a list of string by converting every elements to string just like I do with userId in this case? Can it be the problem and how can I fix it? Thank you for your time!
org.postgresql.util.PSQLException: ERROR: argument of AND must be type boolean, not type record. The same problem happens to "AND (:status IS NULL OR (a.status IN :status)) "
I think using COALESCE(:status) IS NULL instead of :status IS NULL will solve above problem.
The following Oracle query runs OK in my DB Client, PL/SQL Developer, and returns 1 result.
On running it via NamedParameterJdbcTemplate (SpringJDBC) in my Java app, I get
java.sql.SQLSyntaxErrorException: ORA-00933: SQL command not properly ended
There can't be any space issues or anything obvious, because this exact query completes in PL/SQL.
private static final String SELECT1 =
" SELECT COUNT(*) "
" FROM table1 t1, table2 t2 " +
" WHERE t1.received_date > TRUNC(sysdate - 1) " +
" AND t1.received_date < TRUNC(sysdate) " +
" AND t1.type IN ('TYPE1', 'TYPE2') " +
" AND t2.received_num = t1.received_num; ";
public int getSelect1() {
HashMap<String,Object> paramMap = new HashMap<String,Object>();
return jdbcTemplate.queryForObject(SELECT1, paramMap, Integer.class);
}
I think you don't require the semi colon with the sql string.
private static final String SELECT1 =
" SELECT COUNT(*) " +
" FROM table1 t1, table2 t2 " +
" WHERE t1.received_date > TRUNC(sysdate - 1) " +
" AND t1.received_date < TRUNC(sysdate) " +
" AND t1.type IN ('TYPE1', 'TYPE2') " +
" AND t2.received_num = t1.received_num ";