<p dir="auto"><strong><a href="https://jira.spring.io/secure/ViewProfile.jspa?name=irwinm" rel="nofollow">Eric Fletcher</a></strong> opened <strong><a href="https://jira.spring.io/browse/SPR-3019?redirect=false" rel="nofollow">SPR-3019</a></strong> and commented</p>
<p dir="auto">The issue appears to be a compatibility issue between Quartz1.6 JDBCJobStore and Spring scheduling.</p>
<p dir="auto">When using a CronTriggerBean to persist a cron trigger a DataTruncationExceptions is being thrown when attempting to insert the trigger.  The stack trace indicates that Quartz is trying to insert a new BlobTrigger instead of a CronTrigger.</p>
<p dir="auto">The issue appears to be a change in how the org.quartz.impl.jdbcjobstore.StdJDBCDelegate checks to see what type of trigger is to be inserted.  The code for the check in the older(1.5.2) version is shown below:</p>
<p dir="auto">[code]<br>
1166            if (trigger instanceof SimpleTrigger) {<br>
1167                ps.setString(10, TTYPE_SIMPLE);<br>
1168            } else if (trigger instanceof CronTrigger) {<br>
1169                ps.setString(10, TTYPE_CRON);<br>
1170            } else { // (trigger instanceof BlobTrigger)<br>
1171                ps.setString(10, TTYPE_BLOB);<br>
[/code]</p>
<p dir="auto">In the older implementations of Quartz's org.quartz.impl.jdbcjobstore.StdJDBCDelegate, it was using an instanceof check to determine the trigger type.  That was fine, since CronTriggerBean subclasses CronTrigger.</p>
<p dir="auto">In Quartz version 1.6, the  trigger type check is now relying on the getClass method, shown below:</p>
<p dir="auto">[code]<br>
if (trigger.getClass() == SimpleTrigger.class) {<br>
ps.setString(10, TTYPE_SIMPLE);<br>
} else if (trigger.getClass() == CronTrigger.class) {<br>
ps.setString(10, TTYPE_CRON);<br>
} else {<br>
ps.setString(10, TTYPE_BLOB);<br>
}<br>
[/code]</p>
<p dir="auto">In this case, the CronTriggerBean (or a SimpleTriggerBean) check is always going to return false, and Quartz is going to try to insert a BlobTrigger all the time, causing the data truncation exception.</p>
<p dir="auto">There are a couple workarounds:<br>
-Use the Trigger directly as a Bean instead of using CronTriggerBean<br>
-Manually enter the trigger record to the database<br>
-swap in the Quartz 1.5.2 jars for the 1.6 jars, start the app and insert the trigger, then go back to 1.6(if desired).</p>
<p dir="auto">I stumbled across the last one and it is what I have tested so far.  The other workarounds should work, but I haven't tested them.</p>
<p dir="auto">This post also describes the issue:<br>
<a href="http://forum.springframework.org/showthread.php?t=33301" rel="nofollow">http://forum.springframework.org/showthread.php?t=33301</a></p>
<hr>
<p dir="auto"><strong>Affects:</strong> 2.0 final</p>
<p dir="auto"><strong>Issue Links:</strong></p>
<ul dir="auto">
<li><a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="398072964" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/7537" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/7537/hovercard" href="https://github.com/spring-projects/spring-framework/issues/7537">#7537</a> Upgrade to Quartz 1.6.1 (for trigger persistence with SimpleTriggerBean and CronTriggerBean) (<em><strong>"duplicates"</strong></em>)</li>
</ul>
<p dir="auto"><strong><a href="https://jira.spring.io/secure/ViewProfile.jspa?name=bjsion" rel="nofollow">Ben Sion</a></strong> opened <strong><a href="https://jira.spring.io/browse/SPR-8210?redirect=false" rel="nofollow">SPR-8210</a></strong> and commented</p>
<p dir="auto">It would be very helpful if the EmbeddedDatabaseBuilder could be configured to continue on error or ignore drop statements when executing schema and data scripts. This would simplify the use of the EmbeddedDatabase for use in unit tests (and probably other scenarios).</p>
<p dir="auto">I have attached a patch for this issue. Basically a new constructor is added to the EmbeddedDatabaseBuilder taking in 2 booleans that configure the underlying DatabasePopulator's ignoreFailedDrops and continueOnError values.</p>
<p dir="auto">I realise that I could create my own DatabasePopulator and execute the scripts outside of the EmbeddedDatabaseBuilder's initialisation but this seems like a lot of extra lines of code. Please let me know if I can provide more information.</p>
<hr>
<p dir="auto"><strong>Affects:</strong> 3.0.5, 3.1 M1</p>
<p dir="auto"><strong>Attachments:</strong></p>
<ul dir="auto">
<li><a href="https://jira.spring.io/secure/attachment/17992/patch-embeddedDB.txt" rel="nofollow">patch-embeddedDB.txt</a> (<em>2.95 kB</em>)</li>
</ul>
<p dir="auto"><strong>Issue Links:</strong></p>
<ul dir="auto">
<li><a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="398165430" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/16037" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/16037/hovercard" href="https://github.com/spring-projects/spring-framework/issues/16037">#16037</a> Improve configurability of EmbeddedDatabaseBuilder (<em><strong>"is superseded by"</strong></em>)</li>
</ul>