When to use $ vs #?

Following the myBatis guidelines #{} is used in your sql statements. If you take a look any of MyBatis Reference in the Section Mapper XML Files it says explicity: Notice the parameter notation: #{id} Otherwise ${} is for 1- Configuration properties. For example: <properties resource=”org/mybatis/example/config.properties”> <property name=”username” value=”dev_user”/> <property name=”password” value=”F2Fa3!33TYyg”/> </properties> Then the properties … Read more

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

I believe the answer is the same as is given in this question. You can use myBatis Dynamic SQL in your annotations by doing the following: @Select({“<script>”, “SELECT *”, “FROM blog”, “WHERE id IN”, “<foreach item=’item’ index=’index’ collection=’list'”, “open='(‘ separator=”,” close=”)”>”, “#{item}”, “</foreach>”, “</script>”}) List<Blog> selectBlogs(@Param(“list”) int[] ids); The <script> element enables dynamic SQL parsing … Read more

Replacing a full ORM (JPA/Hibernate) by a lighter solution : Recommended patterns for load/save?

This kind of problem is typical when not using a real ORM, and there is no silver bullet. A simple design approach that worked for me for a (not very big ) webapp with iBatis (myBatis), is to use two layers for persistence: A dumb low-level layer: each table has its Java class (POJO or … Read more

Difference between ibatis and mybatis

MyBatis is a fork from iBATIS, and according to Wikipedia most of iBATIS’ developers moved over to MyBatis too. The iBATIS project is currently marked as Inactive, therefore you should go with MyBatis for new projects and only use iBATIS if you’re maintaining an existing project which already uses iBATIS. http://en.wikipedia.org/wiki/MyBatis MyBatis is a fork … Read more

MyBatis, how to get the auto generated key of an insert? [MySql]

For me it is working like this (mybatis 3.x) .. The id must be set auto increment in mysql table <insert id=”createEmpty” parameterType=”Project” useGeneratedKeys=”true” keyProperty=”project.projectId” keyColumn=”PROJECT_ID”> INSERT INTO PROJECT (TITLE,DESCRIPTION) VALUES (#{title},#{description}) </insert> NOTE keyProperty=”project.projectId” and useGeneratedKeys=”true” my interface is: public int createEmpty(@Param(“project”) Project project, @Param(“title”) String title, @Param(“description”) String description); finally to get the … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)