ibatis

Using different datasources for particular queries with Spring and IBATIS

I have the requirement of updating an app to use multiple (i.e., two in this case) datasources depending upon the type of query. For instance, use DB1 for reads and DB2 for write operations. How would I approach this? ...

"Invalid SQL statement or JDBC escape, terminating '}' not found." with jTDS and Sybase.

I'm calling a stored procedure via ibatis. It works, and has worked, when using the jconn2.jar (5.5). When I swap it out for the jtds jar (1.2.5) I get an exception "Invalid SQL statement or JDBC escape, terminating '}' not found." For more transparency I'm using Spring with DBCP. Obviously the parsing of the SQL code in jTDS is not bei...

iBatis get executed sql

Hi all. Is there any way where I can get the executed query of iBatis? I want to reuse the query for an UNION query. For example: <sqlMap namespace="userSQLMap"> <select id="getUser" resultClass="UserPackage.User"> SELECT username, password FROM table WHERE id=#value# </select> </sqlMap> ...

iBatis - select environment using XML

I have this configuration in ibatis-config.xml <configuration> <properties resource="collector.properties"/> <environments default="development"> <environment id="development"> <transactionManager type="JDBC" /> <dataSource type="POOLED"> <property name="driver" value="${dev.jdbc.d...

Spring + iBatis + Hessian caching

Hi. I have a Hessian service on Spring + iBatis working on Tomcat. I'm wondering how to cache results... I've made the following config in my sqlmap file: <sqlMap namespace="Account"> <cacheModel id="accountCache" type="MEMORY" readOnly="true" serialize="false"> <flushInterval hours="24"/> <flushOnExecute statement="Account.a...

Transaction management in iBATIS 3 inside an EJB (3.1) container

Is anybody out there using iBATIS 3 as their persistence framework inside an EJB container? I recently started building a new system for which I choose EJB 3.1 (the version of EJB is actually irrelevant to this question) as my app framework and iBATIS 3 (this version is relevant!) as my persistence framework. My business logic is impleme...

Can a JMock mock object return another mock object?

I'm writing tests for an application using the iBatis DAO framework. The app is running in a java 1.4 environment, so I'm using legacy versions of everything (JDK 1.4, JUnit3, iBatis 2.3 and JMock 1.2). In my MockObjectTestCase subclass I have this test public void testInsert() throws Exception { Mock mockDao = mock(TblPpvFiltersD...

ORM in the realworld

I am begining a new project that i think will last for some years. Am in the point of deciding the ORM framework to use (or whether to use one at all). Can anyone with experience tell me whether orm frameworks are used in realworld applications. The problem i have in mind is this: The orm tool will generate for me tables and columns etc ...

How to use stored procedure or function in iBatis 3 (with annotation)

I want to use Oracle stored procedure or function via 'iBATIS 3 for Java' with annotation. But I can't find any sample codes. Can anyone help me? I need a simple sample code. ...

iBatis mapping: map a string field into a List<String>

Hi all, is it possible to map a string field with a particular format like: aaa,bbb,ccc,ddd into a List having elements [aaa, bbb, ccc, ddd] using iBatis? What I need is to have in my model something like: public class Request{ private List<String> fieldOne; public List<String> getFieldOne(){....} public void setFieldOn...

Call a statement from resultMap->result iBatis

Hi All, Please tell me is it correct configuration in given below. If there are mistake please reply. <resultMap class="beans.Payment" id="paymentResult"> <select id="getOrderPayments" resultMap="paymentResult"> select * from PAYMENT where ORDER_ID = #ordId# and CUST_ID = #ordCustId# <select id=...

How to get a result from SP output parameter in iBATIS 3(by using annotation)?

Hi there, How to get a result from output parameter of stored procedure(Oracle)? Below is my code. Does anyone can help me? Oracle Stored Procedure: CREATE OR REPLACE PROCEDURE getProducts ( rs OUT SYS_REFCURSOR ) IS BEGIN OPEN rs FOR SELECT * FROM Products; END getProducts; Interface: public interface ProductMapper { ...

ibatis domain modelling

Hi team; I am working on the domain model for a project. I have a class named user that has a class named UserType as one of the properties. I know when i want to select all users, i will use joins to pick up all corresponding usertypes. How do i do inserts? Do i have to write a handler for userType? or can i do something like INSERT...

ibatis problem using <isNull> whilst iterating over a List

Hi, I'm new to iBatis and I'm struggling with the and elements. I want to iterate over a List of Book instances (say) that are passed in as a HashMap: MyParameters. The list will be called listOfBooks. The clause of the overall SQL statement will therefore look like this: <iterate prepend="AND" property="MyParameters.listOfBooks" ...

What is the best way to iterate over a large result set in JDBC/iBatis 3?

We're trying to iterate over a large number of rows from the database and convert those into objects. Behavior will be as follows: Result will be sorted by sequence id, a new object will be created when sequence id changes. The object created will be sent to an external service and will sometimes have to wait before sending another one...

iBatis using a set for a resultMap as well as a parameterMap

Hi all, I want to pass a Set of Strings in an iBatis query for the parameter map as well as return a collection of strings for the result set. Is this possible? Example queries ... SELECT * FROM some_table t WHERE t.some_column IN (values); UPDATE some_table t SET t.some_column = 'some_value' WHERE t.other_column IN (values); Walt...

ibatis isNotEmpty with multiple variables

Suppose I have a massive table called inactiveUsers and a search form. I want to conditionally join the inactiveUsers table if any user related characteristic is chosen (address, name, phoneNumber, etc...). Is there any way to do this without the following: <isNotEmpty property="address">JOIN inactiveUsers</isNotEmpty> <isNotEmpty prope...

UndeclaredThrowableException due to SQLException in Spring + iBatis?

Hello, I am getting the following exception when I typo the SQL driver name or the database server is offline, basically any SQLException. I can't determine where the UndeclaredThrowableException is coming from. Line 194 in SqlMapClientTemplate is this: logger.debug("Obtained JDBC Connection [" + springCon + "] for iBATIS operation...

iBatis multiple parameter mapper method

Hi, Let's say I have a query getUser with two parameters - userName and password. I'd like to have a mapper method looking like this: public UserBean getUser(String userName, String password); Is there any way I can achieve something like that? Or maybe I should pass in my mapper method map of parameters (and some parameterMap in my ...

Does a library exist with Joda Time / iBATIS integration classes?

It looks like I have to implement com.ibatis.sqlmap.client.extensions.TypeHandlerCallback for both DateTime and LocalDateTime Joda types. This isn't a big deal, but if it's implemented somewhere else I'd rather just use that. ...