I agree with Larry - this is silly.
 
However, it should work.  I think the issue is all the session stuff.  openSession starts a different session - so you're doing transactional work in one session, and executing queries in another session.  Remove the the call to openSession, then just do the transactional calls on the sqlMap itself.  There is hardly ever a reason to do openSession (which starts a DIFFERENT session than the one used by the other SqlMapClient calls).
 
Also - you don't need the CDATA tags.  It's not causing the problem, but it's a bad habit to get into.
 
Jeff Butler


 
On 10/20/06, Larry Meadors <[EMAIL PROTECTED]> wrote:
Let me get this straight...you are doing an insert, and then selecting
row count to see if it's one to make sure it works?

That's, uhm, silly.

If your driver doesn't throw an exception, it's pretty safe to assume
that your single row insert successfully inserted one row.

If not, do EVERYTHING IN YOUR POWER to switch databases, because that
sort of failure is inexcusable from a database vendor.

Larry


On 10/20/06, Javier Leyba <[EMAIL PROTECTED]> wrote:
> On 10/20/06, jamesst < [EMAIL PROTECTED]> wrote:
> > make sure you have an endTransaction(); That is what really does the
> > commit this should be done in the finally clause unless you have auto
> > commit true..
> >
>
>
> Well, I've it:
>
> -------------------------
> try {
>                         sqlMap = NotificationsSqlConfig.getSqlMapInstance();
>                         session = sqlMap.openSession();
>                         session.startTransaction();
>
>
>                         sqlMap.insert("insertTopic", topicBean);
>
>                         gr = (GenericResult) sqlMap.queryForObject("operationResult");
>
>                         session.commitTransaction();
>
>                 } catch (Exception e) {
>                         logger.error ("insertTopic(TopicBean) " +
>                                         "Exception en first try ", e); //$NON-NLS-1$
>                         e.printStackTrace();
>                         throw new RemoteException( e.getMessage(), e);
>                 } finally {
>                         try {
>                                 session.endTransaction();
>                         } catch (SQLException e) {
>                                 logger.warn("updateTopic(String, String, " +
>                                                 "String) - exception finally", e); //$NON-NLS-1$
>                         } finally {
>                                 session.close();
>                         }
>                 }
>
> -------------------
>
>
>
> IBatis configured as:
>
> --------------
> <transactionManager type="JDBC" commitRequired="true">
>                 <dataSource type="JNDI">
>                         <property name="context.java.naming.factory.initial "
>
> value="org.jnp.interfaces.NamingContextFactory" />
>                         <property name="context.java.naming.provider.url"
>                                 value="jnp://localhost:2199" />
>                         <property name="context.java.naming.factory.url.pkgs"
>                                 value="org.jboss.naming:org.jnp.interfaces" />
>                         <property name="DataSource"
>                                 value="java:comp/env/jdbc/MySQLDB" />
>                         <property name="JDBC.DefaultAutoCommit" value="false" />
>                 </dataSource>
>         </transactionManager>
> -------------
>
>
>
> And my query is:
>
> ----------------
>
> <insert id="insertTopic" parameterClass="topic">
>                 <![CDATA[
>                         INSERT INTO topic (
>                         topic.topic_id,
>                         topic.topic_description
>                         ) VALUES (#id#, #description#);
>          ]]>
>         </insert>
> -----------
>
> and
>
> ----------
> <select id="operationResult" resultClass="genericResult">
>                 <![CDATA[
>                 SELECT ROW_COUNT() AS result;
>         ]]>
>         </select>
> ---------
>
>
> Data is correctly inserted, but result is -1...   it´s driving me nuts !!!
>
> J
>

Reply via email to