Fixed: Type mismatch when filtering InventoryItem by availableToPromiseTotal in FixedAssetMaintServices (OFBIZ-13448)#309
Open
toaditi wants to merge 1 commit into
Conversation
…seTotal in FixedAssetMaintServices (OFBIZ-13448) The condition compared the availableToPromiseTotal field against the String literal "0". InventoryItem.availableToPromiseTotal is a fixed-point (BigDecimal) field, so binding a String value throws a ClassCastException when the query is executed (SqlJdbcUtil casts the value to java.math.BigDecimal). Use BigDecimal.ZERO instead.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Jira: https://issues.apache.org/jira/browse/OFBIZ-13448
Problem
In
FixedAssetMaintServices.issueInventory, the InventoryItem lookup builds a condition comparingavailableToPromiseTotalagainst the String literal"0":InventoryItem.availableToPromiseTotalis afixed-pointfield (java.math.BigDecimal,NUMERIC(18,6)). When the query executes,SqlJdbcUtilbinds the value by casting it tojava.math.BigDecimal, so passing aStringthrows aClassCastException(String cannot be cast to BigDecimal). The equivalent EECA (product/entitydef/eecas.xml) avoids this by declaringtype="BigDecimal"on the value; the Java path had no such coercion.Fix
Use
BigDecimal.ZEROinstead of the string"0", and add thejava.math.BigDecimalimport.Verification
./gradlew compileJava→ BUILD SUCCESSFUL.This is the same fix proposed on the Jira issue, corrected: the issue text used
BigDecimal.Zero(does not compile) and omitted the required import.