Comments (2)
I believe, my issue has similar nature, so I append message to this one.
I have fully described parameter mapping, including javaType and jdbcType, but
when I try to insert object with ull fields into database (Oracle 10g) - I've
got same message: "Error setting null parameter"
Here is mapping:
...
<parameterMap id="PatchStatusParam" type="map">
<parameter property="id" javaType="Long" jdbcType="INTEGER" typeHandler="org.apache.ibatis.type.LongTypeHandler"/>
<parameter property="patch" javaType="Long" jdbcType="INTEGER" typeHandler="org.apache.ibatis.type.LongTypeHandler"/>
<parameter property="database" javaType="Long" jdbcType="INTEGER" typeHandler="org.apache.ibatis.type.LongTypeHandler"/>
<parameter property="applyDate" javaType="Date" jdbcType="TIMESTAMP" typeHandler="org.apache.ibatis.type.DateTypeHandler"/>
<parameter property="applyStatus" javaType="String" jdbcType="VARCHAR" typeHandler="org.apache.ibatis.type.StringTypeHandler"/>
</parameterMap>
...
<insert id="PatchStatus.create" parameterMap="PatchStatusParam">
<selectKey keyProperty="id" order="BEFORE" resultType="Long" statementType="STATEMENT">
SELECT PATCH_JOURNAL.PATCH_TARGET_SQ.NEXTVAL AS ID FROM DUAL
</selectKey>
INSERT INTO PATCH_JOURNAL.PATCH_TARGET(ID, PATCH_ID, DB_ID, APPLY_DATE, APPLY_STATUS)
VALUES (#{id}, #{patch}, #{database}, #{applyDate}, #{applyStatus})
</insert>
...
Here is code:
SqlSession session = null;
try {
session = getSession();
for (PatchStatus ref: value){
HashMap param = new HashMap();
param.put("id", ref.getId());
param.put("patch", ref.getPatch().getId());
param.put("database", ref.getDatabase().getId());
param.put("applyDate", ref.getApplyDate());
param.put("applyStatus", ref.getApplyStatus());
session.insert(QUERY_PATCH_STATUS_SUBMIT, param);
}
session.commit();
} catch (Exception e) {
LOGGER.log(Level.SEVERE, ERRMSG_DATA_CREATE, e);
} finally {
if (session!=null){
session.close();
}
}
return value;
At this moment, applyDate may be null, and if is - I have "Error setting null
parameter".
Original comment by [email protected]
on 2 Nov 2010 at 8:02
from mybatis.
Not a bug. You must specify the jdbcType in the parameter mapping for all
nullable fields.
MyBatis 3.0.4 added the ability to specify jdbcType=ARRAY also.
Original comment by [email protected]
on 7 Jan 2011 at 10:03
- Changed state: Invalid
- Added labels: Component-SqlMaps
from mybatis.
Related Issues (20)
- [mybatis-spring] Mapper scanning should not rely on proprietary @Mapper annotation HOT 1
- Migrations archive unzips to "ibatis-migrations" instead of "mybatis-migrations" HOT 2
- OSGI Support HOT 4
- Remove mapper order restriction when referencing SQL fragment in another file. HOT 40
- Non-existent object id is incorrectly resolved when there is an entry with the same short name. HOT 13
- Allow applying @Transactional to types and interfaces and add a @NoTransaction attribute HOT 4
- Please prioritize issues HOT 1
- Adjust issue's status HOT 1
- Unable to get auto-generated ID with mysql using annotations HOT 1
- Mybatis-spring doesn't propagate exceptions up the stack when using batch mode HOT 17
- how to free temp tablespace allocated for a select stmt return parameter HOT 1
- rollback on BatchExecutor executes batched statements HOT 8
- resultMap doesn't support mapping of unnamed columns by index HOT 2
- mybatis3.0.3 bug in WebService ?? HOT 2
- Annotation-based and AOP-based sessions HOT 3
- Global parameter typeHandler not invoked in case of null values HOT 2
- Exception: Result Maps collection does not contain value for test.User-result HOT 2
- Handling of update counts before result sets in select HOT 8
- configure behavior when all columns values are null for some rows HOT 5
- queryForMap does not use a column as map HOT 14
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 mybatis.