Giter VIP home page Giter VIP logo

Comments (2)

GoogleCodeExporter avatar GoogleCodeExporter commented on September 26, 2024
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.

GoogleCodeExporter avatar GoogleCodeExporter commented on September 26, 2024
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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.