ot: Stupid geeks tricks
I have remote ibatis returning DB error messages: http://www.sandrasf.com/node/23 -- RiA-SoA w/JDNC http://www.SandraSF.com forums - help develop a community My blog http://www.sandrasf.com/adminBlog
raltation and inserts
Hi again.. Yes i see a very simple insert and update in the Developer Guide, but no complex, like this one se i have an Account class and multiple Group classes for this account. and the account class has a property ArrayList groups getter setter and this property is mapped this way: typeAlias alias=account type=dk.graveyard.vod.ibatis.Account/ typeAlias alias=group type=dk.graveyard.vod.ibatis.Group/ resultMap id=accountResult class=account result property=id column=ACCOUNT_ID/ result property=name column=ACCOUNT_NAME/ result property=password column=PASSWORD/ result property=status column=STATUS_NAME/ result property=groups column=ACCOUNT_ID select=getGroupsByAccountId/ /resultMap resultMap id=groupResult class=group result property=id column=GROUP_ID/ result property=name column=GROUP_NAME/ /resultMap i cant just figure out how to map this n:m relation, for the insert and update 1 Account can have many Groups 1 Group Can belong to many Accounts do i need to batch it with something like: updateAccount deleteAccountGroupRealtion insertNewAccountGroupRelation every time i change an Account ?? or is there a more friendly way to do it ? i tried a insert mapping for the relation table but.. insert id=insertAccountGroupsByAccount parameterClass=account iterate property=groups INSERT INTO ACCOUNT_GROUP_REF VALUES ( #id#, #groups[].id# ) /iterate /insert but i get an exception: 2281 [thread-pool-98] DEBUG jdbc.SimpleDataSource - Checked out connection 19318506 from pool. 2312 [thread-pool-98] DEBUG sql.Connection - {conn-100038} Connection 2312 [thread-pool-98] DEBUG sql.PreparedStatement - {pstm-100039} PreparedStatement:INSERT INTO ACCOUNT_GROUP_REFVALUES( ?, ?) ;INSERT INTO ACCOUNT_GROUP_REFVALUES( ?, ?) 2312 [thread-pool-98] DEBUG sql.PreparedStatement - {pstm-100039} Parameters: [1, 1, 1, 2] 2312 [thread-pool-98] DEBUG sql.PreparedStatement - {pstm-100039} Types: [java.lang.Integer, java.lang.Integer, java.lang.Integer, java.lang.Integer] 2312 [thread-pool-98] DEBUG jdbc.SimpleDataSource - Returned connection 19318506 to pool. com.ibatis.common.jdbc.exception.NestedSQLException: --- The error occurred while applying a parameter map. --- Check the insertAccountGroupsByAccount-InlineParameterMap. --- Check the statement (update failed). --- Cause: java.sql.SQLException: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '; INSERT INTO ACCOUNT_GROUP_REF VALUES( Caused by: java.sql.SQLException: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '; INSERT INTO ACCOUNT_GROUP_REF VALUES( at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeUpdate(GeneralStatement.java:86) at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.insert(SqlMapExecutorDelegate.java:446) at com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.insert(SqlMapSessionImpl.java:87) at com.ibatis.sqlmap.engine.impl.SqlMapClientImpl.insert(SqlMapClientImpl.java:56) Hi, I have 2 classes: Account private int id; private String username; private String password; private Collection groups; Group private int id; private String name; the db has 3 tables; ACCOUNT GROUP ACCOUNT_GROUP_REF where ACCOUNT_GROUP_REF is a join table for my relations, with 2 collumns: ACCOUNT_ID GROUP_ID Now my question is how do i keep my ACCOUNT_GROUP_REF updated, the Developer guide describes how to setup selects only, but what about insert and updates, of the relations ?? Regards, David Nielsen
Insert for Complex object
Hi, I understand that iBATIs 2.0.9 provides a simple way to map ResultSet to Complex object. (e.g. Category has many Products and Products has Items) My question is, Can we do same thing for INSERT also?? e.g. If I want to insert Category object using StoredProcedure, what will be the simplest way to do it in iBATIs? can we write a ParameterMap for this kind of object mapping? any help is appreciated. Thanks, shilpa
Are IBatis dynamic queries cached on the server side?
I assume you use Preparedstatments querying the DB. As I understand from my DBA, it is important to cache these prepared statments to make Oracle faster. Could you let me know if IBatis caches these? 1. static (i.e. simple SQL queries) 2. dynamic (i.e. queries that get modified with isEqual, etc If so, where is it documented? Thank you, - Roberto
Is the cache working ?
Hi: is there any debug trace that indicates if the cache is working ? I have configured a cache (see below): cacheModel id=ExternalSystem-cache type=MEMORY readOnly=true serialize=false flushInterval minutes=15/ property name=reference-type value=STRONG/ /cacheModel statement id=findById resultMap=defaultResult parameterClass=java.lang.String cacheModel=ExternalSystem-cache select * from ExternalSystem where ID=#value# /statement .. and in debug mode I still get trace like below: 2005.01.10 20:33:46,378 [main] DEBUG java.sql.PreparedStatement (PreparedStatementLogProxy.java:45) - {pstm-18} PreparedStatement: select * from ExternalSystem where ID=? 2005.01.10 20:33:46,378 [main] DEBUG java.sql.PreparedStatement (PreparedStatementLogProxy.java:46) - {pstm-18} Parameters: [DISN] 2005.01.10 20:33:46,378 [main] DEBUG java.sql.PreparedStatement (PreparedStatementLogProxy.java:47) - {pstm-18} Types: [java.lang.String] Is it possible that the cache is NOT working in this particular case ?
Re: Are IBatis dynamic queries cached on the server side?
Couple of things: 1) You can't cache any statement that changes. So if you're talking about dynamic statements, they cannot be cached, because most likely they change on nearly every request. 2) It is not entirely true that caching ALL prepared statements will make your system faster. In fact, keeping such resources reserved unecessarily would be a drain on system resoures. 3) This is a driver responsibility. I've implemented prepared statement caching in the past. It's hard, problematic and best left to the vendors, as different databases will react differently to a given cache strategy (think timeouts or open cursor limits in Oracle). If it is as important as you'd expect, Oracle will have implemented it in their driver. Cheers, Clinton On Tue, 11 Jan 2005 10:59:24 -0500, Roberto Dorich [EMAIL PROTECTED] wrote: I assume you use Preparedstatments querying the DB. As I understand from my DBA, it is important to cache these prepared statments to make Oracle faster. Could you let me know if IBatis caches these? 1. static (i.e. simple SQL queries) 2. dynamic (i.e. queries that get modified with isEqual, etc If so, where is it documented? Thank you, - Roberto
Re: Is the cache working ?
Anything is possible. Are the object references equal? (obj1 == obj2) Clinton On Mon, 10 Jan 2005 20:51:46 -0500, Carl Brodeur [EMAIL PROTECTED] wrote: Hi: is there any debug trace that indicates if the cache is working ? I have configured a cache (see below): cacheModel id=ExternalSystem-cache type=MEMORY readOnly=true serialize=false flushInterval minutes=15/ property name=reference-type value=STRONG/ /cacheModel statement id=findById resultMap=defaultResult parameterClass=java.lang.String cacheModel=ExternalSystem-cache select * from ExternalSystem where ID=#value# /statement .. and in debug mode I still get trace like below: 2005.01.10 20:33:46,378 [main] DEBUG java.sql.PreparedStatement (PreparedStatementLogProxy.java:45) - {pstm-18} PreparedStatement: select * from ExternalSystem where ID=? 2005.01.10 20:33:46,378 [main] DEBUG java.sql.PreparedStatement (PreparedStatementLogProxy.java:46) - {pstm-18} Parameters: [DISN] 2005.01.10 20:33:46,378 [main] DEBUG java.sql.PreparedStatement (PreparedStatementLogProxy.java:47) - {pstm-18} Types: [java.lang.String] Is it possible that the cache is NOT working in this particular case ?
Re: Insert for Complex object
Yes, iBATIS supports stored procedures. It's fully documented in the developer guide. As for cascading updates, that is not supported and probably won't be. It's a complex pattern that often ends up doing more damage than good. Clinton On Tue, 11 Jan 2005 18:17:21 + (UTC), ibatis-new-user [EMAIL PROTECTED] wrote: Hi, I understand that iBATIs 2.0.9 provides a simple way to map ResultSet to Complex object. (e.g. Category has many Products and Products has Items) My question is, Can we do same thing for INSERT also?? e.g. If I want to insert Category object using StoredProcedure, what will be the simplest way to do it in iBATIs? can we write a ParameterMap for this kind of object mapping? any help is appreciated. Thanks, shilpa
Re: Insert for Complex object
Why not just use a loop or some other iteration technique? You are talking about saving 3-4 lines of code per instance, which is not terribly significant, IMO. On Tue, 11 Jan 2005 18:17:21 + (UTC), ibatis-new-user [EMAIL PROTECTED] wrote: Hi, I understand that iBATIs 2.0.9 provides a simple way to map ResultSet to Complex object. (e.g. Category has many Products and Products has Items) My question is, Can we do same thing for INSERT also?? e.g. If I want to insert Category object using StoredProcedure, what will be the simplest way to do it in iBATIs? can we write a ParameterMap for this kind of object mapping? any help is appreciated. Thanks, shilpa
Re: 2.0.9 CLOB
Yes, Download the newest jdbc drivers from oracle. That will fix the 4kb problem. Nathan On Jan 10, 2005, at 3:09 PM, Mitchell, Steve wrote: Can the new Default CLOB/BLOB Handlers in 2.0.9 be used with Oracle 9i? I looked in http://issues.apache.org/jira/browse/IBATIS-4 for iBATISClob.zip, but I didn't find the ZIP file there. I tried using the 2.0.9 default CLOB Handler with Oracle, but it only works with data less than 4 KB. If I have more than 4 KB of data I get java.sql.SQLException: Data size bigger than max size for this type: . My mapping looks like this: insert id=insertProductRequirement parameterClass=com.serff.prl.core.ProductRequirement INSERT INTO PRODUCT_REQ (PRODUCT_REQ_ID, DESCRIPTION, FILING_TYPES, PRODUCT_ID, PRODUCT_REQ_CAT_ID, SERFF_STATE_ID, DATE_LAST_MODIFIED, USER_LAST_MODIFIED, DATE_CREATED, USER_CREATED) VALUES (#id:NUMERIC#, #description:CLOB#, #filingTypes:VARCHAR#, #product.id:NUMERIC#, #productRequirementCategory.id:NUMERIC#, #state.id:NUMERIC#, #lastModified#, #userLastModified:VARCHAR#, #dateCreated#, #userCreated:VARCHAR#) /insert