Hi!
I have declared a sequence in Postgres and try to use it in a selectKey
statement that runs before an insert:
<insert id="insert" parameterType="MessageSummary">
<selectKey keyProperty="id" resultType="int" order="BEFORE">
SELECT nextval('messages_id_seq')
</selectKey>
INSERT INTO messages (id, folder, uid, subject, deliverydate,
date, from, size, attachments, expunged, read)
VALUES (#{id}, #{folder.id}, #{uid}, #{subject},
#{deliveryDate}, #{date}, #{from}, #{size}, #{attachments}, #{expunged},
#{read})
</insert>
This yields the following exception:
org.apache.ibatis.exceptions.IbatisException:
### Error updating database. Cause:
org.apache.ibatis.type.TypeException: JDBC requires that the JdbcType
must be specified for all nullable parameters.
### The error may exist in no/tornado/mail/mappers/MessageMapper.xml
### The error may involve
no.tornado.mail.mappers.MessageMapper.insert-Inline
### The error occurred while setting parameters
### SQL: SELECT nextval('messages_id_seq')
### Cause: org.apache.ibatis.type.TypeException: JDBC requires that the
JdbcType must be specified for all nullable parameters.
at
org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:8)
at
org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:95)
at
org.apache.ibatis.session.defaults.DefaultSqlSession.insert(DefaultSqlSession.java:82)
at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:49)
at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:18)
The query for nextval() returns an integer. None of the columns in the
database are nullable, and the SQL it's complaining about doesn't
contain any parameters at all.
I have another statement using the same syntax that actually works:
<insert id="insert" parameterType="MailFolder">
<selectKey keyProperty="id" resultType="int" order="BEFORE">
SELECT nextval('folders_id_seq')
</selectKey>
INSERT INTO folders (id, userid, uidvalidity, parent, path)
VALUES (#{id}, #{userId}, #{uidValidity}, #{parent.id,jdbcType=NUMERIC},
#{path})
</insert>
This table has one nullable column. Both sequences are created using the
same syntax (CREATE sequence <sequence-name>;)
Am I doing something wrong, or could this be a bug?
Sincerely,
Edvin Syse
---------------------------------------------------------------------
To unsubscribe, e-mail: user-java-unsubscr...@ibatis.apache.org
For additional commands, e-mail: user-java-h...@ibatis.apache.org