ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Larry Meadors" <lmead...@apache.org>
Subject Re: MySQL query problem
Date Fri, 20 Oct 2006 12:33:02 GMT
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 <xleyba@gmail.com> wrote:
> On 10/20/06, jamesst <s.james@logicacmg.com> 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
>

Mime
View raw message