ibatis

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 ...

sql: how to improve this statment.

Hi, I have the following sql statement that I need to make quicker. There are 500k rows, and I an index for 'HARDWARE_ID', but this still take up to a second to perform. Does anyone have any ideas? select * from DEVICE_MONITOR DM where DM.DM_ID = ( select max(DM_ID) ...

Generating DAO with iBATIS problem

Hi, I have created a table in MSSQL having following structure - **Table Name - TestTable** id (int) (Primary key) name (varchar) owner (varchar) I have given Identity specification for column 'id' with auto increment with 1 for each new row. When I created iBatis artifacts for TestTable, the insert function is getting generated, in...

MySql.Data.MySqlClient.MySqlException: Timeout expired

In recent times, a particular page in my web app throws the Exception Details: MySql.Data.MySqlClient.MySqlException: Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding. Though I use Ibtais as persistence layer, this error occurs. I have restarted the MySql service instanc...

Working with Oracle ref cursor using iBatis

Hi! While using JDBC, we can work with oracle ref cursors using CallableStatement. Can I have such functionality using iBatis? ...

How do I convert this sql string into an ibatis sql string?

My sql string looks like this. And What I'd like to do is change it into a format ibatis can use SELECT distinct( dbo.vwChangeMgmt1.number ) FROM dbo.vwChangeMgmt1, dbo.vwChangeMgmtTask1 WHERE dbo.vwChangeMgmt1.Asgn_Group != 'WTO-AMS-NOVUS' and dbo.vwChangeMgmtTask1.Resource_group = 'WTO-AMS-NOVUS' and dbo.vwChang...

manageable way to handle exceptions in java

I am trying to come up with a manageable way to handle exceptions in a DAO. Typically a method in my DAO looks like this: public ArrayList fetchColors (String id) { //call iBatis SqlMapClient //put results in a list //return list } If an error happens in the above code then everything is written to server.log and on the f...

In Ibatis, how does one write a nested Iterate tag to loop through a two-dimensional array?

Hi all, I was troubleshooting the following code and was unable to find an answer, so I figured I would document my solution. The problem was: <iterate property="twoDimArray" prepend="and (" close=")" conjunction="or"> <iterate property="twoDimArray[]" open="(" close=")" conjunction="and"> $twoDimArray[][].columnName$ = #twoDimArray[]...

how to set SqlMapClientTemplate from spring xml

I've got following java class. package com.org.data.dbresource; import org.springframework.orm.ibatis.SqlMapClientTemplate; public class DBConnectionManager { private SqlMapClientTemplate sqlMapClientTemplate; public void setSqlMapClientTemplate (SqlMapClientTemplate sq) { this.sqlMapClientTemplate = sq; } ...

IBatis sql fragments used in different namespace

Hi Guys, I've got a sql fragments defined in a particular namespace like: <sqlMap namespace="firstNamespace"> ..... <sql id="fragmentOne"> and then from another namespace I'm trying to use it, but seems that IBatis is not able to find it. Could not find SQL statement to include with refid 'firstNamespace.fragmentOne' Now ...

Iterate List<Map> in Ibatis

How to Iterate List in Ibatis. query is: delete from table where (column1='tes10' and column2='NET1' and column3='ENG1') OR (column1='TEST22' and column2='NET2' and column3='ENG2') OR (column1='TEST21' and column2='NET3' and column3='ENG3'). I put column values in map and then i wil...

Truncating strings

Hey, I'm working with third party user data that may or may not fit into our database. The data needs to be truncated if it is too long. We are using IBatis with Connector/J. If the data is too long a SQL exception is thrown. I have had two choices: either truncate the strings in Java or truncate the strings in sql using substring. I...

Any Performance solution for retrieving online status from MySQL database.

Hi Guys; I have a large chat application in the build process and i'm confused about how to solve this issue .. i need to show the online status of 10 users on a page at a given time for which i'm using a database query and every time someone visits the page the query is executed and returns the user who are online ... problem is the on...

iBatis schemas not working in Visual Studio 2010

iBatis comes with three schema files that provide intellisense to VS.Net. According to the iBatis help docs, the location should be this: C:\Program Files\Microsoft Visual Studio 10.0\Common7\Packages\schemas\xml or this if you have x64 installed: C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\Packages\schemas\xml The...

When does the cachemodel in ibatis re-query the database to get updated records?

hi; I'm using ibatis and its cache model for the first time and i cant seem to figure out at what time will the cache be filled with new results, meaning whne will the query that i'm applying cache model on be executed again to fill the cache with new results. Does it require some sort of command to get the results again or will it be d...

When does the cachemodel in ibatis re-query the database to get updated records?

0 down vote favorite hi; I'm using ibatis and its cache model for the first time and i cant seem to figure out at what time will the cache be filled with new results, meaning whne will the query that i'm applying cache model on be executed again to fill the cache with new results. Does it require some sort of command to get the resul...

Select Query Optimization

I have select query that fetch record based on a condition Select * from Employee where EmpStatus=#EmpStatus# The EmpStatus in the DB for each employee would either 0 or 1. EmpID EmpName EmpStatus *********************** 1 Name1 0 2 Name2 0 3 Name4 1 4 Name5 1 When I pass EmpStatus as 1, I should get list co...

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...

Cannot get a connection, pool exhausted

Hi, I am using Spring,ibatis. I have configured following in xml file <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> <property name="driverClassName"><value>${driverClassName}</value></property> <property name="url"><value>${url}</value></property> <property name="u...

Hibernate vs iBatis

We are building a fairly database centric web application. We initially started off using iBatis. At one point we thought iBatis may not be very useful for the following reasons: 1. Need for the appl. code to determine if we need to insert/update/delete from DB 2. Appl. code will deviate from being object oriented to being database ori...