RestDataPanacheException: Failed to list the entities when table is empty - spring-data-jpa

When I call an API that finds all entries in a table, and that table is empty, this is the result I expect when using spring-boot-starter-data-jpa:
But when using quarkus-hibernate-orm-panache it throws a 500 error saying
Mapping an unhandled RestDataPanacheException: io.quarkus.rest.data.panache.RestDataPanacheException: Failed to list the entities
Caused by: java.lang.IllegalArgumentException: Page index must be >= 0 : -1
Somehow when my table is empty, my page index is -1 instead of 0.
The exception itself comes from quarkus-rest-data-panache. Is this a bug in that package? Or how can I make it return an empty list?
It seems to be the implementation class of org.springframework.data.rest.core.annotation.RepositoryRestResource calling the pagination from io.quarkus.panache.common with a negative index.
Also I'm pretty sure the issue is with quarkus-spring-data-rest as that's where the exception is from.

Related

PutDatabaseRecord failed with Index header CSVRecord

We are trying to insert data to postgresql based database.
We use PutDatabaseRecord processor with following configurations :
But we get an warning and data is not inserted to database and records are not inserted.
Is this apache commoncsv related issue?
How can I solve this issue?
Edit :
After #matt's initial answer : I found intersting thing with data, in address field it has :
"No 60, Marine Drive,"
CSVReader in PutDatabaseRecord uses , value separator. So address must be read as 3 different column values.
The error seems to indicate you have more columns in the header than in (some lines of) data. If that's not the case, I suspect there's either a bug when handling empty columns, or Infer Schema doesn't work as expected with an empty column in the first row (how would it be able to guess the type of "nothing"?).

value too large in quartz in jboss

I am getting following error in the server log. I would like to know which query(insert or update) making changes on the column of a quartz table.
ERROR [org.quartz.impl.jdbcjobstore.JobStoreTX] MisfireHandler: Error
handling misfires: Couldn't store trigger: ORA-01438: value larger
than specified precision allowed for this column
org.quartz.JobPersistenceException: Couldn't store trigger: ORA-01438:
value larger than specified precision allowed for this column [See
nested exception: org.quartz.JobPersistenceException: Couldn't store
trigger: ORA-01438: value larger than specified precision allowed for
this column [See nested exception: java.sql.SQLException: ORA-01438:
value larger than specified precision allowed for this column ]] at
org.quartz.impl.jdbcjobstore.JobStoreTX.doRecoverMisfires(JobStoreTX.java:1354)
at
org.quartz.impl.jdbcjobstore.JobStoreSupport$MisfireHandler.manage(JobStoreSupport.java:2449)
at
org.quartz.impl.jdbcjobstore.JobStoreSupport$MisfireHandler.run(JobStoreSupport.java:2468)
* Nested Exception (Underlying Cause) --------------- org.quartz.JobPersistenceException: Couldn't store trigger: ORA-01438:
value larger than specified precision allowed for this column [See
nested exception: java.sql.SQLException: ORA-01438: value larger than
specified precision allowed for this column ] at
org.quartz.impl.jdbcjobstore.JobStoreSupport.storeTrigger(JobStoreSupport.java:964)
at
org.quartz.impl.jdbcjobstore.JobStoreSupport.recoverMisfiredJobs(JobStoreSupport.java:780)
at
org.quartz.impl.jdbcjobstore.JobStoreTX.doRecoverMisfires(JobStoreTX.java:1352)
at
org.quartz.impl.jdbcjobstore.JobStoreSupport$MisfireHandler.manage(JobStoreSupport.java:2449)
at
org.quartz.impl.jdbcjobstore.JobStoreSupport$MisfireHandler.run(JobStoreSupport.java:2468)
* Nested Exception (Underlying Cause) --------------- java.sql.SQLException: ORA-01438: value larger than specified
precision allowed for this column
at
oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:331) at
oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:288) at
oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:743) at
oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:216)
at
oracle.jdbc.driver.T4CPreparedStatement.executeForRows(T4CPreparedStatement.java:955)
at
oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1168)
at
oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3285)
at
oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:3368)
at
org.jboss.resource.adapter.jdbc.WrappedPreparedStatement.executeUpdate(WrappedPreparedStatement.java:365)
at
org.quartz.impl.jdbcjobstore.StdJDBCDelegate.updateSimpleTrigger(StdJDBCDelegate.java:1440)
at
org.quartz.impl.jdbcjobstore.JobStoreSupport.storeTrigger(JobStoreSupport.java:942)
at
org.quartz.impl.jdbcjobstore.JobStoreSupport.recoverMisfiredJobs(JobStoreSupport.java:780)
at
org.quartz.impl.jdbcjobstore.JobStoreTX.doRecoverMisfires(JobStoreTX.java:1352)
at
org.quartz.impl.jdbcjobstore.JobStoreSupport$MisfireHandler.manage(JobStoreSupport.java:2449)
at
org.quartz.impl.jdbcjobstore.JobStoreSupport$MisfireHandler.run(JobStoreSupport.java:2468)
Could you please any one help on this. Is there any configuration parameter to see the insert/update queries in the log?
I have seen this error due to the TIMES_TRIGGERED column in the SIMPLE_TRIGGERS table growing too large to be stored in the column, which is normally defined as NUMBER(7) (i.e. max value of 9999999).
Normally, you can just set this column to 0 and the error will go away (until the TIMES_TRIGGERED gets big enough again). It seems like quartz looks at the start time of the trigger and the configured frequency and determines what the value should be and overrides your update, though in my experience it has set it to something well below the max.
See Couldn't store trigger for more details.

DB2 ERRORCODE=-4229, SQLSTATE=null

I'm getting this error while executing a batch operation.
Use getNextException() to retrieve the exceptions for specific batched elements.ERRORCODE=-4229, SQLSTATE=null
I'm not finding any pointer to proceed with debugging this error.
Appreciating any help!!!
Search for the error on the IBM page:
http://publib.boulder.ibm.com/infocenter/dzichelp/v2r2/index.jsp?topic=%2Fcom.ibm.db2z10.doc.java%2Fsrc%2Ftpc%2Fimjcc_rjvjcsqc.htm
-4229 Message text: text-from-getMessage Explanation: An error occurred during a batch execution.
User response: Call SQLException.getMessage to retrieve specific
information about the problem.
So, it might be related to any underlying error during the execution of your batch insert/update/delete
For those who are looking for an solution to this error.
For me this was due to
THE INSERT OR UPDATE VALUE OF FOREIGN KEY constraint-name IS INVALID.
DB2 SQL Error: SQLCODE=-530, SQLSTATE=23503
In my case, this occurred because I had an unique covering index defined on two columns and the combination of these two values was not unique when I was inserting the records.
For anyone who is still wondering, try entering a unique record and check if the error still persists?
For me it was because of duplicate entry of a foreign key.
In my case, this was due to having rows in the database with the same PK IDs that the sequence was generating. The solution can be to fix these "future" row IDs or adapt the sequence to jump those numbers.

How do i get the ordinal of a column in a DataReader

How can i find out if a column exists in a DataReader's results set?
i try:
int columnOrdinal = reader.GetOrdinal("LastName");
columnExists = (columnOrdinal < 0);
but GetOrdinal throws an exception if the column does not exist. My case is not exceptional. It's the opposite. It's...ceptional.
Note: Not related to my question but, the real reason i want to know if a column exists is because i want to get the ordinal position of a column, without throwing an exception if the column doesn't exist:
int columnOrdinal = reader.GetOrdinal("Lastname");
Note: Not related to my question but, the real reason i want to know if a column exists, because i want to know if the column contains null:
itIsNull = reader.IsDBNull(reader.GetOrdinal("Lastname"));
Unfortunately IsDBNull only takes an ordinal, and GetOrdinal throws an exception. So i'm left with:
if (ColumnExists(reader, "Lastname"))
{
itIsNull = reader.IsDBNull(reader.GetOrdinal("Lastname"));
}
else
itIsNull = false;
Note: Not related to my question but, the real reason i want to know if a column exists is because there will be times where the column will not be present in the results set, and i don't want to throw an exception processing database results, since it's not exceptional.
There is a limit to what you can do since the IDataReader doesn't expose much that helps. Using the loop as shown in the answer to a similar question
Check for column name in a SqlDataReader object
You could, with the first row you process, build a simple dictionary that is keyed by column name with ordinals as values (or a HashSet if you don't care about the ordinal values). Then you can just use columnDictionary.ContainsKey("LastName") as your test. You would only build the dictionary once, for the first row encountered, then all the subsequent rows would be fast.
But to be honest, compared with database time, the time consumed by using as-is the solution in that other stackoverflow qeustion would probably be negligible.
Edit: additional possibilities here: Checking to see if a column exists in a data reader

Verify if insert was successful in Symfony2/Doctrine/MongoDB

My application is not alerting me to a failed insert when adding a record to a MongoDB collection with a unique index...
$dm->flush()
... does not complain. I'm trying to figure out what the array parameter to flush should look like to see if that helps but getting nowhere. flush does not return anything on success or failure.
Any ideas on how I can verify, in my PHP/Symfony2 application, whether the insert worked without needing to query the db immediately after inserting?
Got it. Per this link, must provide array("safe" => true) as a parameter to the write operation.
$dm->flush(array('safe'=>true));
So when using the code above and trying to insert into a unique index an exception will be thrown.