Re: nested javabeans properties
Hello Brandon, here is my detailed query: select id=selectEvents parameterClass=ListOfConditions resultClass=LoggingBean![CDATA[ select le_level as level, le_location as location, le_logger as logger, le_message as message, le_ndc as ndc, le_thread as thread, le_throwable as throwable, le_timestamp as timeStampAsDate from log_events where ]] iterate conjunction=OR property=list open=( close=) ![CDATA[ (#list[].level# = -1 OR #list[].level# $list[].levelOperator$ le_level) AND (#list[].logger# = '' OR le_logger LIKE #list[].logger#) AND (#list[].timestampSeconds# = -1 OR #list[].timestampSeconds# $list[].timestampOperator$ (extract(epoch from le_timestamp)::integer)) $list[].attributesSubQuery$ ]] /iterate as you see, at the end there is $list[].attributesSubQuery$, which is subqueries generated in Java, like this: for (Iterator it = attributes.iterator(); it.hasNext();) { KeyValue kv = (KeyValue) it.next(); sb .append( AND EXISTS (select 1 from log_event_attributes) .append( where lea_event = le_id) .append( and lea_value LIKE ') .append(kv.getValue()) .append( ' and lea_key = (select lk_id from log_keys where lk_name=') .append(kv.getKey()).append(')) ); } So, is this possible to express everthing in ibatis xml, without this dirty $list[].attributesSubQuery$? Micha Maecki - Original Message - From: Brandon Goodin [EMAIL PROTECTED] To: ibatis-user-java@incubator.apache.org Sent: Saturday, January 01, 2005 8:41 PM Subject: Re: nested javabeans properties have you looked into the isPresent, isEqual, isNotEqual,etc.. tags yet? Otherwise, you will need to be more specific. It is difficult to help out with ambiquous scenarios in dynasql. Brandon On Fri, 31 Dec 2004 12:35:14 +0100, Micha Maecki [EMAIL PROTECTED] wrote: Hello Clinton, I have class Condition { int timestamp; Vector attributes; //Vector of key-value class int level; /* constructors, getters, setters, etc*/ } I would like to pass List of condition objects, and to generate following query select . from log_events where ( --first Condition object conditions for timestamp and level multiple subqueries for each element of attributes Vector ) OR ( --second Condition object conditions for timestamp and level multiple subqueries for each element of attributes Vector ). So I have to use first iterate element for the big condition (connected using OR) and nested iterate for all subqueries built using attribute Vector; How can this be done?? Micha Clinton Begin wrote: Hi Michal, is it planned to add support for nested javabeans properties, also collections? iBATIS supports both of these already. I don't understand enough about what you're asking to know how to help you. Can you provide some code examples? Clinton
postgresql: idle in transaction
Hi, I am trying to avoid that all my connections ends up in state idle in transaction like this: [EMAIL PROTECTED]:~$ ps ax | grep postres: secure 11249 ?S 0:00 postgres: secure db 192.168.2.121 idle in transaction With the old version af iBatis and our php projects, that status is only idle (unless the connection is currently working on a query). Clinton Begin advised me to try transactionManager type=JDBC commitRequired=true in the config file. I am going to use this setting anyway so my stored procedures work correctly, but it does not seem to have any effect on the idle in transaction problem. It does not seem to have any bad effects on the system, but from a system admin perspective I would like to avoid it, so I can have my scripts warn me if those starts piling up. They are a sign that somebody is not handling their transactions correctly. Baldur
Re: subselects design
Clinton Begin ha scritto: Hi Emiliano, Couple of things: 1) It looks like product and/or price are 1:1 Or M:1 with your parent object, so why not just join the data? I would avoid the second select, as you're creating an N+1 problem (1 primary select + 100 --one for each record). Even if it's a collection, version 2.0.9 can handle joined data for populating complex collections. well, it's not so simple the getPrice method, for example, retrieve the first value of a list of values returned by subselect for price so I can't convert it in a direct join I'm looking at the new features of 2.0.9... -- Emiliano Armellin W_ www.ateikon.com @_ [EMAIL PROTECTED] T_ +39 0422 452101 inline: trust.gifinline: thunderbird_small.png
Re: Re: Re: java.lang.NoClassDefFoundError when using ibatis
I recommend putting all of your SQL Map resources in the WEB-INF/classes folder. Otherwise, you might have to jump through some hoops to load them from a jar file. This goes for any resources, not just SQL Map XML files. Clinton On Tue, 4 Jan 2005 11:53:43 +0700, Dody Rachmat Wicaksono [EMAIL PROTECTED] wrote: You'll need to look at the full logs as per the message at the bottom of the stack trace. NoClassDefFoundError is a secondary exception. i found no log file, /tomcat/log is empty found this in tomcat console sql-map-config.xml is not found i wonder why the sql files is not packaged in jar file thanks a lot.
Type Handler Exception in xml parser
Here is the error.. Exception in thread main java.lang.ExceptionInInitializerError at reporting.viewer.service.ReportService.init(ReportService.java:30) at reporting.viewer.service.ReportService.clinit(ReportService.java:26) at reporting.viewer.util.DataBaseLoader.main(DataBaseLoader.java:27) Caused by: com.ibatis.dao.client.DaoException: Error while configuring DaoManager. Cause: java.lang.RuntimeException: Error occurred. Cause: com.ibatis.common.xml.NodeletException: Error parsing XML. Cause: org.xml.sax.SAXParseException: Element sqlMapConfig does not allow typeHandler here. Caused by: org.xml.sax.SAXParseException: Element sqlMapConfig does not allow typeHandler here. Caused by: java.lang.RuntimeException: Error occurred. Cause: com.ibatis.common.xml.NodeletException: Error parsing XML. Cause: org.xml.sax.SAXParseException: Element sqlMapConfig does not allow typeHandler here. Caused by: org.xml.sax.SAXParseException: Element sqlMapConfig does not allow typeHandler here. at com.ibatis.dao.engine.builder.xml.XmlDaoManagerBuilder.buildDaoManager(X mlDaoManagerBuilder.java:126) at com.ibatis.dao.client.DaoManagerBuilder.buildDaoManager(DaoManagerBuilde r.java:59) at reporting.viewer.dao.DaoConfig.clinit(DaoConfig.java:35) ... 3 more Caused by: java.lang.RuntimeException: Error occurred. Cause: com.ibatis.common.xml.NodeletException: Error parsing XML. Cause: org.xml.sax.SAXParseException: Element sqlMapConfig does not allow typeHandler here. Caused by: org.xml.sax.SAXParseException: Element sqlMapConfig does not allow typeHandler here. at com.ibatis.sqlmap.engine.builder.xml.SqlMapConfigParser.parse(SqlMapConf igParser.java:80) at com.ibatis.sqlmap.engine.builder.xml.SqlMapConfigParser.parse(SqlMapConf igParser.java:68) at com.ibatis.sqlmap.client.SqlMapClientBuilder.buildSqlMapClient(SqlMapCli entBuilder.java:78) at com.ibatis.dao.engine.transaction.sqlmap.SqlMapDaoTransactionManager.con figure(SqlMapDaoTransactionManager.java:52) at com.ibatis.dao.engine.builder.xml.XmlDaoManagerBuilder.parseTransactionM anager(XmlDaoManagerBuilder.java:190) at com.ibatis.dao.engine.builder.xml.XmlDaoManagerBuilder.parseContext(XmlD aoManagerBuilder.java:154) at com.ibatis.dao.engine.builder.xml.XmlDaoManagerBuilder.buildDaoManager(X mlDaoManagerBuilder.java:99) ... 5 more Caused by: com.ibatis.common.xml.NodeletException: Error parsing XML. Cause: org.xml.sax.SAXParseException: Element sqlMapConfig does not allow typeHandler here. Caused by: org.xml.sax.SAXParseException: Element sqlMapConfig does not allow typeHandler here. at com.ibatis.common.xml.NodeletParser.parse(NodeletParser.java:51) at com.ibatis.sqlmap.engine.builder.xml.SqlMapConfigParser.parse(SqlMapConf igParser.java:77) ... 11 more Caused by: org.xml.sax.SAXParseException: Element sqlMapConfig does not allow typeHandler here. at org.apache.crimson.parser.Parser2.error(Parser2.java:3354) at org.apache.crimson.parser.ValidatingParser$ChildrenValidator.consume(Val idatingParser.java:349) at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1497) at org.apache.crimson.parser.Parser2.content(Parser2.java:1963) at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1691) at org.apache.crimson.parser.Parser2.parseInternal(Parser2.java:667) at org.apache.crimson.parser.Parser2.parse(Parser2.java:337) at org.apache.crimson.parser.XMLReaderImpl.parse(XMLReaderImpl.java:448) at org.apache.crimson.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.ja va:185) at com.ibatis.common.xml.NodeletParser.createDocument(NodeletParser.java: 148) at com.ibatis.common.xml.NodeletParser.parse(NodeletParser.java:48) ... 12 more Java Result: 1 BUILD SUCCESSFUL (total time: 1 second) here is the sqlMapConfig file... ?xml version=1.0 encoding=UTF-8 standalone=no? !DOCTYPE sqlMapConfig PUBLIC -//iBATIS.com//DTD SQL Map Config 2.0//EN http://www.ibatis.com/dtd/sql-map-config-2.dtd; sqlMapConfig settings cacheModelsEnabled=true enhancementEnabled=true maxSessions=64 maxTransactions=8 maxRequests=128 useStatementNamespaces=false/ transactionManager type=JDBC dataSource type=SIMPLE property name=JDBC.Driver value=oracle.jdbc.driver.OracleDriver/ property name=JDBC.ConnectionURL value=jdbc:oracle:thin:@oradevdb1.central.sun.com:1541:DEVLAM/ !--property name=JDBC.ConnectionURL value=jdbc:oracle:thin:@datastore.central.sun.com:1525:UBRRPTAM/-- property name=JDBC.Username value=WEBAPPS_APP/ property name=JDBC.Password value=WEBAPPS_APP/ !--Optional Properties -- property name=Pool.MaximumActiveConnections value=20/ property name=Pool.MaximumIdleConnections value=3/ /dataSource /transactionManager typeHandler
Re: update inside stored procedure
What's the exception? On Tue, 04 Jan 2005 08:49:37 -0800, Paul Woods [EMAIL PROTECTED] wrote: I thought I had a similiar problem to what the poster of http://www.mail-archive.com/ibatis-user-java@incubator.apache.org/msg00135.html had, and I tried the solution that worked for him, but without success. After doing as suggested I am not getting any exceptions, but there are no apparent updates being performed on the database either. Just to verify, my transactionManager tag now looks like: transactionManager type=JDBC commitRequired=true ... datasource stuff ... The procedure inside the sqlMap file is: procedure id=increment parameterMap=incrementMap { call incProc(?, ?) } /procedure I'm calling it with (update/insert threw exceptions for me): sqlMap.queryForObject(increment, map); I'm using postgresql 7.3, the stored procedure works fine when called from psql. I tried ibatis 2.0.8 w/o luck, and just saw and tried 2.0.9 w/ the same results. Thanks for any help provided. Love ibatis. Paul
Re: Type Handler Exception in xml parser
TypeHandler has to be above the TX Manager On Tue, 04 Jan 2005 09:49:05 -0700, Nathan Maves [EMAIL PROTECTED] wrote: Here is the error.. Exception in thread main java.lang.ExceptionInInitializerError at reporting.viewer.service.ReportService.init(ReportService.java:30) at reporting.viewer.service.ReportService.clinit(ReportService.java:26) at reporting.viewer.util.DataBaseLoader.main(DataBaseLoader.java:27) Caused by: com.ibatis.dao.client.DaoException: Error while configuring DaoManager. Cause: java.lang.RuntimeException: Error occurred. Cause: com.ibatis.common.xml.NodeletException: Error parsing XML. Cause: org.xml.sax.SAXParseException: Element sqlMapConfig does not allow typeHandler here. Caused by: org.xml.sax.SAXParseException: Element sqlMapConfig does not allow typeHandler here. Caused by: java.lang.RuntimeException: Error occurred. Cause: com.ibatis.common.xml.NodeletException: Error parsing XML. Cause: org.xml.sax.SAXParseException: Element sqlMapConfig does not allow typeHandler here. Caused by: org.xml.sax.SAXParseException: Element sqlMapConfig does not allow typeHandler here. at com.ibatis.dao.engine.builder.xml.XmlDaoManagerBuilder.buildDaoManager(X mlDaoManagerBuilder.java:126) at com.ibatis.dao.client.DaoManagerBuilder.buildDaoManager(DaoManagerBuilde r.java:59) at reporting.viewer.dao.DaoConfig.clinit(DaoConfig.java:35) ... 3 more Caused by: java.lang.RuntimeException: Error occurred. Cause: com.ibatis.common.xml.NodeletException: Error parsing XML. Cause: org.xml.sax.SAXParseException: Element sqlMapConfig does not allow typeHandler here. Caused by: org.xml.sax.SAXParseException: Element sqlMapConfig does not allow typeHandler here. at com.ibatis.sqlmap.engine.builder.xml.SqlMapConfigParser.parse(SqlMapConf igParser.java:80) at com.ibatis.sqlmap.engine.builder.xml.SqlMapConfigParser.parse(SqlMapConf igParser.java:68) at com.ibatis.sqlmap.client.SqlMapClientBuilder.buildSqlMapClient(SqlMapCli entBuilder.java:78) at com.ibatis.dao.engine.transaction.sqlmap.SqlMapDaoTransactionManager.con figure(SqlMapDaoTransactionManager.java:52) at com.ibatis.dao.engine.builder.xml.XmlDaoManagerBuilder.parseTransactionM anager(XmlDaoManagerBuilder.java:190) at com.ibatis.dao.engine.builder.xml.XmlDaoManagerBuilder.parseContext(XmlD aoManagerBuilder.java:154) at com.ibatis.dao.engine.builder.xml.XmlDaoManagerBuilder.buildDaoManager(X mlDaoManagerBuilder.java:99) ... 5 more Caused by: com.ibatis.common.xml.NodeletException: Error parsing XML. Cause: org.xml.sax.SAXParseException: Element sqlMapConfig does not allow typeHandler here. Caused by: org.xml.sax.SAXParseException: Element sqlMapConfig does not allow typeHandler here. at com.ibatis.common.xml.NodeletParser.parse(NodeletParser.java:51) at com.ibatis.sqlmap.engine.builder.xml.SqlMapConfigParser.parse(SqlMapConf igParser.java:77) ... 11 more Caused by: org.xml.sax.SAXParseException: Element sqlMapConfig does not allow typeHandler here. at org.apache.crimson.parser.Parser2.error(Parser2.java:3354) at org.apache.crimson.parser.ValidatingParser$ChildrenValidator.consume(Val idatingParser.java:349) at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1497) at org.apache.crimson.parser.Parser2.content(Parser2.java:1963) at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1691) at org.apache.crimson.parser.Parser2.parseInternal(Parser2.java:667) at org.apache.crimson.parser.Parser2.parse(Parser2.java:337) at org.apache.crimson.parser.XMLReaderImpl.parse(XMLReaderImpl.java:448) at org.apache.crimson.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.ja va:185) at com.ibatis.common.xml.NodeletParser.createDocument(NodeletParser.java: 148) at com.ibatis.common.xml.NodeletParser.parse(NodeletParser.java:48) ... 12 more Java Result: 1 BUILD SUCCESSFUL (total time: 1 second) here is the sqlMapConfig file... ?xml version=1.0 encoding=UTF-8 standalone=no? !DOCTYPE sqlMapConfig PUBLIC -//iBATIS.com//DTD SQL Map Config 2.0//EN http://www.ibatis.com/dtd/sql-map-config-2.dtd; sqlMapConfig settings cacheModelsEnabled=true enhancementEnabled=true maxSessions=64 maxTransactions=8 maxRequests=128 useStatementNamespaces=false/ transactionManager type=JDBC dataSource type=SIMPLE property name=JDBC.Driver value=oracle.jdbc.driver.OracleDriver/ property name=JDBC.ConnectionURL value=jdbc:oracle:thin:@oradevdb1.central.sun.com:1541:DEVLAM/ !--property name=JDBC.ConnectionURL value=jdbc:oracle:thin:@datastore.central.sun.com:1525:UBRRPTAM/-- property name=JDBC.Username value=WEBAPPS_APP/ property name=JDBC.Password value=WEBAPPS_APP/ !--Optional Properties --
Re: IBatis and Oracle stored functions
For instance: ... CallableStatement cstmt = conn.prepareCall({? = call pkg_refcur.f_refcur(?)}); cstmt.registerOutParameter(1, OracleTypes.CURSOR); cstmt.setString(2, i_etype); cstmt.executeUpdate(); ResultSet rset = ((OracleCallableStatement)cstmt).getCursor(1); ... I've seen *part* of an example for a custom type handler, but no real complete example including call sequence. This would help a great deal! Thx, Jan. Clinton Begin wrote: How would you call them from JDBC? iBATIS supports pretty much anything supported by the standard JDBC APIs. Vendor specific extensions typically require a custom type handler, or may not be supportable at all. Clinton On Tue, 04 Jan 2005 18:43:52 +0100, Jan Vissers [EMAIL PROTECTED] wrote: Hi, I'm evaluating IBatis sqlMap/DAO wrt Oracle functionality, like: RETURNING ... INTO ... Clause CLOB (oracle.sql.CLOB) 32K BLOB (oracle.sql.BLOB) XMLType (oracle.xdb.XMLType) CallableStatement... It looks to me that none of these are really supported. I, for instance have a packaged function: function insert_record( p_i_values in pck2.refcursortype) return pck2.refcursortype; Is there any way to call these types of objects from IBatis? Thx. Jan. -- And -- Get Firefox! http://www.spreadfirefox.com/?q=affiliatesid=0t=70 And Get Thunderbird http://www.mozilla.org/products/thunderbird/
Re: IBatis and Oracle stored functions
Jan Vissers wrote: Hi, I'm evaluating IBatis sqlMap/DAO wrt Oracle functionality, like: * CLOB (oracle.sql.CLOB) 32K * BLOB (oracle.sql.BLOB) For CLOB, try using Oracle 10g drivers (even if RDBMS is 9.2) and pass a property SetBigStringTryClob=true to the driver. This makes Oracle CLOBs almost standard compliant. I had some problems with 10g thin drivers, which crashed at 4000 chars. Works fine with OCI, though. Set the property that either on connection pool definition or programmatically: --- Properties props = new Properties(); props.put(SetBigStringTryClob, true); connection = DriverManager.getConnection(jdbc:oracle:thin:scott/[EMAIL PROTECTED]:1521 :o rclbox1, props); --- Anyway, Oracle CLOBS are a pain in the ***, even in 10g. That is true for iBatis, plain JDBC and Hibernate. As for BLOBs, I'll have to investigate the issue no matter what, as I'll have to use them on a project next week... It looks to me that none of these are really supported. I, for instance have a packaged function: function insert_record( p_i_values in pck2.refcursortype) return pck2.refcursortype; I suppose this function is a type unsafe insert? If it isn't (if refcursor's type is static), you could try mapping refcursor to a table object type. But as Clinton said, try a custom type handler. Cheers, bd
Re: IBatis and Oracle stored functions
You can look at the Blob and ClobTypeHandlerCallback implementations included with 2.0.9 as an example of a CTH. As fot the getCursor stuff, you won't have access to the PreparedStatement, but you should be able to use getObject(1) to get the cursor back. In the worst case scenario, 2.0.9 includes support for implementing full TypeHandler implementations, which are harder to write, but will give you access to the PS. Cheers Clinton On Tue, 04 Jan 2005 19:05:56 +0100, Jan Vissers [EMAIL PROTECTED] wrote: For instance: ... CallableStatement cstmt = conn.prepareCall({? = call pkg_refcur.f_refcur(?)}); cstmt.registerOutParameter(1, OracleTypes.CURSOR); cstmt.setString(2, i_etype); cstmt.executeUpdate(); ResultSet rset = ((OracleCallableStatement)cstmt).getCursor(1); ... I've seen *part* of an example for a custom type handler, but no real complete example including call sequence. This would help a great deal! Thx, Jan. Clinton Begin wrote: How would you call them from JDBC? iBATIS supports pretty much anything supported by the standard JDBC APIs. Vendor specific extensions typically require a custom type handler, or may not be supportable at all. Clinton On Tue, 04 Jan 2005 18:43:52 +0100, Jan Vissers [EMAIL PROTECTED] wrote: Hi, I'm evaluating IBatis sqlMap/DAO wrt Oracle functionality, like: RETURNING ... INTO ... Clause CLOB (oracle.sql.CLOB) 32K BLOB (oracle.sql.BLOB) XMLType (oracle.xdb.XMLType) CallableStatement... It looks to me that none of these are really supported. I, for instance have a packaged function: function insert_record( p_i_values in pck2.refcursortype) return pck2.refcursortype; Is there any way to call these types of objects from IBatis? Thx. Jan. -- And -- Get Firefox! http://www.spreadfirefox.com/?q=affiliatesid=0t=70 AndGet Thunderbird http://www.mozilla.org/products/thunderbird/
Re: IBatis and Oracle stored functions
Of course, if this is a single case, you might just want to use JDBC too... Clinton On Tue, 4 Jan 2005 11:30:59 -0700, Clinton Begin [EMAIL PROTECTED] wrote: You can look at the Blob and ClobTypeHandlerCallback implementations included with 2.0.9 as an example of a CTH. As fot the getCursor stuff, you won't have access to the PreparedStatement, but you should be able to use getObject(1) to get the cursor back. In the worst case scenario, 2.0.9 includes support for implementing full TypeHandler implementations, which are harder to write, but will give you access to the PS. Cheers Clinton On Tue, 04 Jan 2005 19:05:56 +0100, Jan Vissers [EMAIL PROTECTED] wrote: For instance: ... CallableStatement cstmt = conn.prepareCall({? = call pkg_refcur.f_refcur(?)}); cstmt.registerOutParameter(1, OracleTypes.CURSOR); cstmt.setString(2, i_etype); cstmt.executeUpdate(); ResultSet rset = ((OracleCallableStatement)cstmt).getCursor(1); ... I've seen *part* of an example for a custom type handler, but no real complete example including call sequence. This would help a great deal! Thx, Jan. Clinton Begin wrote: How would you call them from JDBC? iBATIS supports pretty much anything supported by the standard JDBC APIs. Vendor specific extensions typically require a custom type handler, or may not be supportable at all. Clinton On Tue, 04 Jan 2005 18:43:52 +0100, Jan Vissers [EMAIL PROTECTED] wrote: Hi, I'm evaluating IBatis sqlMap/DAO wrt Oracle functionality, like: RETURNING ... INTO ... Clause CLOB (oracle.sql.CLOB) 32K BLOB (oracle.sql.BLOB) XMLType (oracle.xdb.XMLType) CallableStatement... It looks to me that none of these are really supported. I, for instance have a packaged function: function insert_record( p_i_values in pck2.refcursortype) return pck2.refcursortype; Is there any way to call these types of objects from IBatis? Thx. Jan. -- And -- Get Firefox! http://www.spreadfirefox.com/?q=affiliatesid=0t=70 AndGet Thunderbird http://www.mozilla.org/products/thunderbird/
Re: update inside stored procedure
I just updated the jdbc jar from postgres, and I can now get updates to work when calling w/ queryForObject. Using insert or update still throw the same exception. On postgresql.stat.result a google found a poster elsewhere regarding postgres In your function, you return 0. My guess is that it's being treated as a result set so that's why executeUpdate will not work. As I understand postgres, I have to have a return of some sort in a stored procedure, so with the above appears to be mucking the use of insert or update in ibatis. Anyhow, this works, though I don't know if it's ideal or not. Thanks again for your help (and ibatis). On Tue, 2005-01-04 at 10:27, Clinton Begin wrote: What is postgresql.stat.result? On Tue, 04 Jan 2005 10:13:18 -0800, Paul Woods [EMAIL PROTECTED] wrote: When using an insert, the exception is com.ibatis.common.jdbc.exception.NestedSQLException The stack reads: Exception in Polls.increment(): com.ibatis.common.jdbc.exception.NestedSQLException: --- The error occurred in com/nwnet/da/bean/maps.xml. --- The error occurred while applying a parameter map. --- Check the increment-InlineParameterMap. --- Check the statement (update procedure failed). --- Cause: postgresql.stat.result Caused by: postgresql.stat.result Thanks again. On Tue, 2005-01-04 at 09:41, Clinton Begin wrote: What's the exception?
Re: IBatis and Oracle stored functions
Regarding {? = call pkg_refcur.f_refcur(?)} where the function returns an (Oracle) REF Cursor and input parameter is another cursor type. What would a possible sqlMap definition look like, for such a function? And How would one call this from within Java? Thx. -J. Clinton Begin wrote: You can look at the Blob and ClobTypeHandlerCallback implementations included with 2.0.9 as an example of a CTH. As fot the getCursor stuff, you won't have access to the PreparedStatement, but you should be able to use getObject(1) to get the cursor back. In the worst case scenario, 2.0.9 includes support for implementing full TypeHandler implementations, which are harder to write, but will give you access to the PS. Cheers Clinton On Tue, 04 Jan 2005 19:05:56 +0100, Jan Vissers [EMAIL PROTECTED] wrote: For instance: ... CallableStatement cstmt = conn.prepareCall("{? = call pkg_refcur.f_refcur(?)}"); cstmt.registerOutParameter(1, OracleTypes.CURSOR); cstmt.setString(2, i_etype); cstmt.executeUpdate(); ResultSet rset = ((OracleCallableStatement)cstmt).getCursor(1); ... I've seen *part* of an example for a custom type handler, but no real complete example including call sequence. This would help a great deal! Thx, Jan. Clinton Begin wrote: How would you call them from JDBC? iBATIS supports pretty much anything supported by the standard JDBC APIs. Vendor specific extensions typically require a custom type handler, or may not be supportable at all. Clinton On Tue, 04 Jan 2005 18:43:52 +0100, Jan Vissers [EMAIL PROTECTED] wrote: Hi, I'm evaluating IBatis sqlMap/DAO wrt Oracle functionality, like: "RETURNING ... INTO ..." Clause CLOB (oracle.sql.CLOB) 32K BLOB (oracle.sql.BLOB) XMLType (oracle.xdb.XMLType) CallableStatement... It looks to me that none of these are really supported. I, for instance have a packaged function: function insert_record( p_i_values in pck2.refcursortype) return pck2.refcursortype; Is there any way to call these types of objects from IBatis? Thx. Jan. -- And -- Get Firefox! http://www.spreadfirefox.com/?q=affiliatesid=0t=70 AndGet Thunderbird http://www.mozilla.org/products/thunderbird/ -- And inline: get.gifinline: thunderbird_small.png
Re: IBatis and Oracle stored functions
Thanks for this complete example! Wondering about two other things though. 1. (Maybe this is a lame question) I ran into serious trouble using a packaged function having not only *output* parameters function get_some( p_i_what in varchar2 , p_i_howmany in number ) return some (REF) cursor type What would this look like from a sqlMap definition point of view and how would one call it? 2. What about using (a) java.sql.rowset.CachedRowSet impl instead of javax.servlet.jsp.jstl.sql.Result? My compliments on this mail list, it is one of the best I've seen so far. -J. Jerome Jacobsen wrote: Hello Jan, Unfortunately I have no stored procedure/function example that does an UPDATE. However, here's the information I have about a PL/SQL FUNCTION that does a SELECT and returns a REFCURSOR. [EMAIL PROTECTED] posted a message to this forum December 22, 2004 with an attached TypeHandler implementation. Subject was Re: Problems with registering OUT parameter in Oracle stored procedure. Here's the link: http://www.mail-archive.com/ibatis-user-java@incubator.apache.org/msg00287.h tml From his example I created one against the Oracle scott/tiger schema. See attached files. The attachments include the entire project including the script to create the test FUNCTION (in SCOTT schema). The exception is that the JAR file dependencies are not attached. See build.xml for the JAR file versions. After building the project you can run RefCursorTest. It will output the records from table EMP. My Environment -- Client - Windows 2000 - JDK 1.4.2_06 - SqlMaps 2.0.9 - Oracle thin JDBC driver 9.0.3 Server - Windows 2000 - Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production As for CLOB, BLOB, XMLType I have no experience with these using ibatis. I've done BLOB/CLOB stuff using JDBC directly but I was using Oracle JDBC API instead of java.sql.*. -Jerome -Original Message- From: Jan Vissers [mailto:[EMAIL PROTECTED] Sent: Tuesday, January 04, 2005 1:06 PM To: ibatis-user-java@incubator.apache.org Subject: Re: IBatis and Oracle stored functions For instance: ... CallableStatement cstmt = conn.prepareCall({? = call pkg_refcur.f_refcur(?)}); cstmt.registerOutParameter(1, OracleTypes.CURSOR); cstmt.setString(2, i_etype); cstmt.executeUpdate(); ResultSet rset = ((OracleCallableStatement)cstmt).getCursor(1); ... I've seen *part* of an example for a custom type handler, but no real complete example including call sequence. This would help a great deal! Thx, Jan. Clinton Begin wrote: How would you call them from JDBC? iBATIS supports pretty much anything supported by the standard JDBC APIs. Vendor specific extensions typically require a custom type handler, or may not be supportable at all. Clinton On Tue, 04 Jan 2005 18:43:52 +0100, Jan Vissers [EMAIL PROTECTED] wrote: Hi, I'm evaluating IBatis sqlMap/DAO wrt Oracle functionality, like: RETURNING ... INTO ... Clause CLOB (oracle.sql.CLOB) 32K BLOB (oracle.sql.BLOB) XMLType (oracle.xdb.XMLType) CallableStatement... It looks to me that none of these are really supported. I, for instance have a packaged function: function insert_record( p_i_values in pck2.refcursortype) return pck2.refcursortype; Is there any way to call these types of objects from IBatis? Thx. Jan. -- And -- Get Firefox! http://www.spreadfirefox.com/?q=affiliatesid=0t=70 And Get Thunderbird http://www.mozilla.org/products/thunderbird/ ?xml version=1.0 encoding=UTF-8 ? !DOCTYPE sqlMap PUBLIC -//iBATIS.com//DTD SQL Map Config 2.0//EN http://www.ibatis.com/dtd/sql-map-2.dtd; sqlMap parameterMap id=noInputsSingleResult class=map parameter property=resultCode jdbcType=NUMERIC mode=OUT/ parameter property=result jdbcType=ORACLECURSOR mode=OUT typeHandler=ResultSetToResultHandler/ /parameterMap procedure id=proc1 parameterMap=noInputsSingleResult ![CDATA[ {?= call IBATIS_REFCURSOR_TEST(?)} ]] /procedure /sqlMap ?xml version=1.0 encoding=UTF-8 ? !DOCTYPE sqlMapConfig PUBLIC -//iBATIS.com//DTD SQL Map Config 2.0//EN http://www.ibatis.com/dtd/sql-map-config-2.dtd; !-- Be sure to always use the appropriate header as above! Note the 2.0 DTDs. -- sqlMapConfig !-- Using the properties element you can declare an external properties resource either from the classpath (resource) or from a URL (e.g. file:// or http://) The properties can be referred to throughout the rest of the file using the syntax ${propName}. There can be only one properties element. -- properties resource=jdbc.properties/ !-- The settings element has a number of configuration switches and