mybatis

MyBatis 3.0.1 insert problem

Hi Everyone! Decided to move one of my project from iBatis to MyBatis and ran into a problem with insert. mapper xml: <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"&gt; <mapper namespace="bap.persistance.interfaces....

Easiest way to verify MyBatis 3.x caching is working properly

Greetings! I'm trying to set up caching for a small MyBatis & Spring app and following their pdf doc my xml mapper contains <cache /> Configuration xml file at the top has settings as follows: <settings> <setting name="cacheEnabled" value="true" /> </settings> logging with log4j is set for DEBUG, but I see no indications th...

How do I insert collection of objects using MyBatis 3.x?

Hi. I'm a beginner with MyBatis. I just want to know how to insert a collection of objects from an instance of a class. Say I have a class User related to a Note in one-to-many relationship. I just like to mention that I built my schema using JPA 2 annotations via Hibernate's hbm2ddl. I'll add the key JPA annotations I used in the sampl...

How to use Annotations with iBatis (myBatis) for an IN query?

We'd like to use only annotations with MyBatis; we're really trying to avoid xml. We're trying to use an "IN" clause: @Select("SELECT * FROM blog WHERE id IN (#{ids})") List<Blog> selectBlogs(int[] ids); MyBatis doesn't seem able to pick out the array of ints and put those into the resulting query. It seems to "fail softly" and we ...

iBatis multiple parameter mapper method called as inline query

Hi, I want to use an inline query in an annotated mapper which gets two parameters. Can I do that? I see in debug that it tries to pass the same parameter twice. I've added the @Param to each parameter of the inline query method but I don't know how to reference the two parameters from the parent query because the column property can ge...

Spring declarative transaction management not working

I am using spring 3.0.3.RELEASE along with mybatis-3.0.2 and mybatis-spring-1.0.0 running in Apache Tomcat 6.0.29 with JDK 1.6.0_21. I created my DAO class and Service class and defined following declarative transaction control - <tx:advice id="txAdvice" transaction-manager="transactionManager"> <tx:attributes> <tx:...

How to add multiple named parameters to the SQL statement?

I would like to write something like this in myBatis (using anotations instead of XML): @Insert("INSERT INTO friendships (user_id, friend_id) VALUES (#{user.id}, {friend.id})") public void insert(User user, User friend); Is this possible? How exactly? (Note, I would like to use Objects of type User for type-safty. I know that using ...

how to get colmn metdata in mybatis

Hi I need to get the list of columns in a table using mybatis/ibatis in java 1.5. ...

problem parsing mybatis xml config file

Hi everyone! I have a problem reading the xml config file for Mybatis 3.0.2. I have to use it in a web service with Axis2 1.5. I have a class whith this code: public static org.apache.ibatis.session.SqlSessionFactory getSqlMapper () { org.apache.ibatis.session.SqlSessionFactory sqlMapper; try { String resource = "MyBatis.xml"; ...

Spring aop transaction not committing the transaction

I am using Spring 3.0.3, MyBatis 3.0.2 and mybatis-spring 1.0.0 on Apache Tomcat 6.0.29. I have used declarative transactions of spring for transaction management. The issue is that the transactions are not working for me. The transaction only works once and thereafter nothing. I have tried checking all my configs but no clue. Any poin...