ibatis

Handling many-to-many inserts with Ibatis

I'm new to Ibatis and have a question regarding the mapping of many-to-many relationships. In my application's data model I have a many-to-many relationship between two of the entities, with the tables in the database looking like this: CREATE TABLE A ( id int PRIMARY KEY ) CREATE TABLE B ( id int PRIMARY KEY ) CREATE TABLE A...

iBatis - Header Detail Question

I'm trying to put some new functionality into an existing app that uses iBatis but I'm a little stuck with one of the design decisions. There is an existing class (call it class A) which I want to add some new fields to. These fields will be of type B. The query will join B via an outer join. So it will be something like public c...

How to assert that database connection is in a transaction?

I'm using an object/relational mapper to talk to the database. The library in my case is iBatis which is also used for transaction management. However, I recently had a case where iBatis didn't actually start a transaction even though startTransaction() etc. was called as documented. After some debugging I found out that there was a conf...

How load xml files, in IntelliJ IDEA

IntelliJ not find xml file under sources folder. example) src/net/saltfactory/domain/PersonSqlMap.xml but, If I copy it and past out folder, IntelliJ find xml file example) out/net/saltfactory/domain/PersonSqlMap.xml I hope that don't copy and past XML files to out folder help me ...

spring + ibatis + mysql result in com.mysql.jdbc.exceptions.jdbc4.CommunicationsException

Hi all, this is a very famous error, however after searching and broswing the web I didn't manage to find a stable and proper solution. We are running an application onto this environment: spring + ibatis + mysql all at their latest version. Very randomly we get this error, and then after some time, which can be hours or days, the erro...

iBatis 3 - JNDI configuration example

The iBatis framework has been significantly tweaked between versions 2 & 3, so much that even the config file (now often referred to as MapperConfig.xml) is different. That being said, there are lots of examples online on how to create a JDBC connection pool with iBatis, but I couldn't find one example on how to do it with JNDI. There ...

how to cope with a null Date in an ibatis mapping

I have the following in one of my result mappings. <result property="updateDate" column="update_date" javaType="java.util.Date" jdbcType="DATE" nullValue="01/01/1900"/> basically updateDate is a setter that accepts Date. However, sometimes updateDate will be null in the database. In those cases I want to have a default date of 01/0...

iBatis circular references question

I have an Office object and a Device Object. An Office has a device and a device belongs to an office. So, obtaining an Office object should populate Office.Device reference and a Device object should have an Office object where it belongs. It's a circular reference I suppose. I'd like to do this in iBATIS, but I can't figure out how ...

how to do logging in iBatis ORM

We use iBatis + Spring intensively. Everything we get from the DB is fetched via stored procedures. At times when troubleshooting an issue we want to know the exact parameters that were sent to the SP and SP name that was executed. Currently we do this by debugging the code (which is a pain). We would like to add some sort of logging...

Is there active development going on IBatis.Net DataMapper?

Is there active development going on IBatis.Net DataMapper? Do they have version for .Net 3.5. I saw lots of activity on iBatis Java DataMapper as they are planning to release iBatis3 with annotation support. What is the status of its .Net counterpart? ...

Mapping parent-child relationships with iBatis

I have the classic setup public class Parent { Integer id; ... // No generics Collection someCollectionAttribute; ... public void setChildren(Collection c) { ... } } public class Child { Integer id; ... } and I'm trying to map this on the usual table setup using iBatis (version 2.30... don'...

Does iBatis enforce a primary key on my table?

Hi guys, I'm working on a legacy project. The database is poorly designed. I want to change the DB layer now. The first think go through my mind is hibernate, but I hibernate need a primary key on my table. In fact some of my table does not have primary key. So I did a google search and I find iBatis, it's sounds very good with it. But ...

Stored procedure output parameter set back to POJO by iBATIS

I'm using iBATIS to call a Stored Procedure on MSSQL Server, the input parameters are properties on a POJO that is put to the map: Map<String, Object> saveMap = new HashMap<String, Object>(); saveMap.put("obj", myArticle); update("save", saveMap); All parameters are set correctly as input to the procedure so nothing wrong there. But o...

How to use my own connection when using iBatis Data Mapper?

How can I use my own connection Provider when using iBatis Data Mapper? I have to use UserId and Password of the user performing the db operation in the ConnectionString? E.g. The following ConnectionString has to be modified to insert the userid and password for user performing the db operation. Data Source=TEST;Persist Security Info=T...

ibatis/Oracle - SELECT query inside INSERT is failing

Hi, I'm trying to do an Insert operation using iBatis. INSERT INTO SCHEMA.TABLE (FIELD1, FIELD2, FIELD3) VALUES (#field1#, (SELECT ANOTHER_FIELD FROM SCHEMA.TABLE WHERE FIELD4= #field2#), #field2#) ...

Why is log4j not behaving as expected?

I have a co-worker who is trying to get log4j to behave as follows: Log to Stdout By default, disable most output Show only messages from java.sql.PrepareStatement at level debug and up He's getting caught up in the 'level' vs 'priority'. Here is his config file: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE log4j:configuration ...

Is NULL not allowed is SQL delete statement (for Derby)?

Hello Does anyone know why the following query fails in Derby? delete from MyTable where ((null = null) or (col1 = null)) OR ((102 = null) or (col2 = 102))) I get the following error: Error: Syntax error: Encountered "null" at line 3, column 3. SQLState: 42X01 ErrorCode: -1 The sql is being generated in a java program based on SQL...

Dump iBatis sql in Nunit?

I saw nHibernate video during the weekend. In the tutorial, the programmer was using MBunit to test his code. One neat thing i liked about nhibernate was, if you tell nhibernate to 'showSql', it displays sql in Mbunit dialog box after the unit test. I was wondering if there is something similar for ibatis using nUnit? ...

Guice + Quartz + iBatis

I'm trying to wire together Guice (Java), Quartz scheduler and iBatis (iBaGuice) to do the following: Start command line utility-scanner using main() Periodically scan directory (provided as argument) for files containing formatted output (XML or YAML) When file is detected, parse and output result to the database The problems: I u...

Use Hibernate and Ibatis in the same application

I need to write a new app but using some data acces logic from other two app. One uses Hibernate and the other uses iBATIS. Can I use in the same app both, Hibernate and iBATIS?. How?. Update: Let me reformule my question. Let's forget I will rehuse some DAOs or domain clases. I need to use in the same app, Hibernate and iBATIS. How can...