Comments (9)
Created pull request #458
from datanucleus-rdbms.
Please provide a simple testcase that demonstrates the problem. Test suites need to be able to recreate such things.
from datanucleus-rdbms.
How can I write a test case that shows how Datanucleus fetch data from the database (in this case which ResultSet getter has been called)?
I have problems with the mapping of SQL queries to ResultObjects (with Oracle 11g).
I have seen in debugger, that there was a call of ResultSet.getObject() for all my number columns.
In Oracle ResultSet.getObject() deliveres a BigDecimal for all number types.
This leads to error messages like
Query needs to return objects of type "..." but it was impossible to set the field "..." type "java.math.BigDecimal". The field should have either a public set/put method, or be public.
I have to add an setter with a BigDecimal parameter to my result class for all number fields (of type short, int, Integer, Long, ...).
from datanucleus-rdbms.
Using ResultSet.getInt()/getLong()/... hides a problem with setting the values in the result object fields.
For example the BigDecimal got from Oracle has to be converted to an int.
This works on the first row of the ResultSet because of the conversion in the catch in ResultClassROF.getObject() line 456 .
For the following rows ResultClassFieldSetter.set will be called directely with the BigDecimal. At this point, there will be no conversion of the BigDecimal to Integer, because Integer is not assignable from BigDecimal (ResultClassROF:889).
This results in the 021204 NucleusUserException in ResultClassROF:343 mentioned above.
from datanucleus-rdbms.
My test case can reproduce the problem but I was able to reproduce the problem with Oracle only.
Strangely it does get no error with 'mvn clean compile test' but if I call SimpleTestMain directly.
test-jdo-sql-ResultSetROF-getObject.zip
from datanucleus-rdbms.
Thx. The testcase reproduces a problem using Junit on Oracle (11g) (no need for any "main"), due to how Oracle JDBC maps types
from datanucleus-rdbms.
Suggest that you try with the change made above, since that is way simpler than your PR and works.for.me
from datanucleus-rdbms.
It looks like your commit solves the conversions problem for Oracle. Thx.
My commit would be an additional enhancement for the way the data is fetched from the ResultSet.
ResultClassROF.getResultObject(ResultSet, int) has an optimization to use the suitable getter (instead of getObject()), if the query has a simple return type. My commit expands this optimization for the fields of the class in case of a class return type.
from datanucleus-rdbms.
Marking as fixed, but retaining PR since would be nice to rework the whole class and could use as part of that
from datanucleus-rdbms.
Related Issues (20)
- Pull Request #422 uses Java9+ methods and shouldn't
- Handling of insert audit attributes (user, timestamp) is incorrect when specified on a field
- Regression with SQL Server caused by #408 HOT 1
- ConnectionFactoryImpl#closeAfterTransactionEnd returns always true HOT 2
- Invalid MySQL schema generated when used with Connector/J 8.0.30 HOT 2
- Support TINYBLOB on MySQL/MariaDB without size specifier, as per TINYTEXT
- Search of setter function in ResultClassROF.getObject() is broken HOT 1
- NullPointerException in ResultClassROF.getObject() in 6.0.2 HOT 6
- ArgType not cached for null value in first Result in ResultSet HOT 1
- Wrong identity type generated for type `long` with PostgreSQL
- datanucleus.query.jdoql.{varName}.join extension does not work when "varName" is not lower case HOT 4
- Support bulk-fetch on a Collection when field is empty
- BatchUpdateException when reordering elements of 1-m relationship as List<> (join table) - with testcase HOT 3
- Provide InitSQL hikari options HOT 2
- Support ConnectionInitSQL with HikariCP
- keyword "COLUMN_NAME" for dm database HOT 3
- `UpdateStmtAllowTableAliasInSet` is not honored for update statements involving `DelegatedExpression`s HOT 1
- Issue #470 doesn't allow for discriminatorColumnName not being in different case
- Provide registerMbeans HikariCP options
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from datanucleus-rdbms.