hi,

Larry Meadors a écrit :
Try changing your included sql fragment to this:

<sql id="insertErreurObjet_fragment">
  insert into FUN_ERR_OBJ (
    numObj, codGi, numLang,
    codInf, typErrObj, libErrObj
  ) values (
    #numObj:INTEGER#, #codGi:VARCHAR#, #numLang:INTEGER#,
    #codInf:VARCHAR#, #typErrObj:VARCHAR#, #libErrObj:VARCHAR#
  )
</sql>

I think if you look in your db, you'll find a row with a null or 0
value for numErrObj, you are trying to insert another with the same id
value. By removing it from the insert, you should be OK.

  
i've emptied the whole table FUN_ERR_OBJ and used your sql fragment but i keep having this error...

my ibatis log looks like :

DEBUG [uPortal thread pool worker #3] sql.Connection.[] oct./11 14:25:45    - {conn-100163} Connection
DEBUG [uPortal thread pool worker #3] sql.PreparedStatement.[] oct./11 14:25:45    - {pstm-100164} PreparedStatement:              select LAST_INSERT_ID()         
DEBUG [uPortal thread pool worker #3] sql.PreparedStatement.[] oct./11 14:25:45    - {pstm-100164} Parameters: []
DEBUG [uPortal thread pool worker #3] sql.PreparedStatement.[] oct./11 14:25:45    - {pstm-100164} Types: []
DEBUG [uPortal thread pool worker #3] sql.PreparedStatement.[] oct./11 14:25:45    - {pstm-100166} PreparedStatement:                    insert into FUN_ERR_OBJ (         numObj, codGi, numLang,         codInf, typErrObj, libErrObj         ) values (         ?, ?, ?,         ?, ?, ?         )                            
DEBUG [uPortal thread pool worker #3] sql.PreparedStatement.[] oct./11 14:25:45    - {pstm-100166} Parameters: [36, GEN, 41, NOM, W, L'information "Libellé" doit être renseignée pour la langue "Anglais"]
DEBUG [uPortal thread pool worker #3] sql.PreparedStatement.[] oct./11 14:25:45    - {pstm-100166} Types: [java.lang.Integer, java.lang.String, java.lang.Integer, java.lang.String, java.lang.String, java.lang.String]
DEBUG [uPortal thread pool worker #3] jdbc.SimpleDataSource.[] oct./11 14:25:45    - Returned connection 4016151 to pool.

you can see that the LAST_INSERT_ID() is issued before the insert...

regards
Larry


On 10/11/05, Olivier Ziller GMail Lists <[EMAIL PROTECTED]> wrote:
  
 hello,

 i've the following statements :

     <sql id="insertErreurObjet_fragment">
         insert into FUN_ERR_OBJ values (#numErrObj:INTEGER#,
#numObj:INTEGER#, #codGi:VARCHAR#, #numLang:INTEGER#,
         #codInf:VARCHAR#, #typErrObj:VARCHAR#, #libErrObj:VARCHAR#)
     </sql>

 and

     <insert id="insertErreurObjet"

parameterClass="fr.unire.portal.channels.fun.csof.beans.ErreurObjet"
    
          <include refid="insertErreurObjet_fragment"/>
         <!--
             insert into FUN_ERR_OBJ values (#numErrObj:INTEGER#,
#numObj:INTEGER#, #codGi:VARCHAR#, #numLang:INTEGER#,
         #codInf:VARCHAR#, #typErrObj:VARCHAR#, #libErrObj:VARCHAR#)
         -->
         <selectKey keyProperty="numErrObj" resultClass="int">
             select LAST_INSERT_ID()
         </selectKey>
     </insert>
 and i always get the following error :

 Caused by: java.sql.SQLException: Duplicate key or integrity constraint
violation message from server

 in the log file, it appears that the select LAS_INSERT_ID() is made before
the insert statements
 it appears only if i use include.
 if i comment my include and uncomment the insert into statement, it works,
the LAST_INSERT_ID is made after the insert!

 is it a bug or something i've made wrong?

 thanks for any help


    

  

Reply via email to