Larry Meadors | 22 Nov 2004 18:12

Re: Flush cache implemented in sqlmap2

They should be. Have you tried them?

>>> Nathan Maves <Nathan.Maves <at> Sun.COM> 11/19/04 12:41 PM >>>
I have found the methods in the SqlmapClient but are they implemented
and do they work?

Aliaksandr Radzivanovich | 23 Nov 2004 12:25
Picon

Custom property editor?

SQL Maps is great framework!

In my current project java.util.Calendar is used to store dates in
bean properties. Does SQLMaps work with this type?

Is this possible to add custom property editor to a bean which would
preprocess/convert property's value somehow before storing or after
reading it from database?

Laurent Duperval | 24 Nov 2004 16:14

Using classes for composite keys

Hello,

I started implementing some classes in Hibernate where the recommended 
procedure is to create a class for your composite key and use that 
instead of multiple fields. Does iBatis support this?

Thanks,

L

Kris Jenkins | 24 Nov 2004 17:23
Picon
Favicon

Re: Custom property editor?

Aliaksandr Radzivanovich wrote:

>SQL Maps is great framework!
>
>In my current project java.util.Calendar is used to store dates in
>bean properties. Does SQLMaps work with this type?
>  
>
Not out of the box.

>Is this possible to add custom property editor to a bean which would
>preprocess/convert property's value somehow before storing or after
>reading it from database?
>
Yes indeed.  Take a look at the javadocs for 
com/ibatis/sqlmap/client/extensions/TypeHandlerCallback.  It includes an 
example of how to write a true/false<->YES/NO mapper which should get 
you started.

HTH,
Kris

PS - Where are the javadocs?  Okay, for now take a look at the source 
file - that's in the distribution under debug/ibatis-debug.jar.

--

-- 
Kris Jenkins
Email: kris <at> jenkster.com
Web:   http://cafe.jenkster.com/

(Continue reading)

Andre Peterka | 19 Nov 2004 17:45
Picon

Socket write error

Hi all

One customer reported a problem to us, that they are getting the following
error message:

com.ibatis.dao.client.DaoException: Error executing
query for object.  Cause: java.sql.SQLException: Io exception: Connection
reset by peer: socket write error

The cause is a restart of the Database while the application is still
running.

The transactionManager is configured via
 <transactionManager type="JDBC" >
	<dataSource type="JNDI">
		<property name="DataSource"
value="java:comp/env/jdbc/dataSourceName"/>
	</dataSource>
 </transactionManager>

Oracle suggest something like the following, when using TopLink, to
reestablish a connection:

	if (clientSession != null)
			db = clientSession;

		if (db == null || !db.isConnected()) {

			logger.info("Login Info:  trying to connect to
ClientSession ...");
(Continue reading)

Rios, Hector | 19 Nov 2004 18:13

ISolation levels


Hi there,

I am relatively new to Sql Maps and was unsure of how to implement
different isolation levels using Sql Maps

I need to implement Synchronized isolation level. Can anyone post an example
of how I would do this.

I have something like this but I don't think this is exactly right.

                SqlMapClient client = SqlMapClientFactory.getSqlMapInstance();
                Connection cn = null;                          
                try
                {
                    cn = client.getDataSource().getConnection();
                    int defaultIsolation = cn.getTransactionIsolation();
                    cn.setTransactionIsolation(Connection.TRANSACTION_SERIALIZABLE);
                    client.setUserConnection(cn);
                    client.startTransaction();                 
                    client.insert(queryName,input);                    
                    client.commitTransaction();
                }
                finally
                {                  
                        client.endTransaction();
                        cn.close();
                }

TIA

-Hector



Please inform us immediately if this e-mail and/or any attachment was transmitted incompletely or was not intelligible. ______________________________________________________________ This e-mail and any attachment is for authorized use by the intended recipient(s) only. It may contain proprietary material, confidential information and/or be subject to legal privilege. It should not be copied, disclosed to, retained or used by any other party. If you are not an intended recipient then please promptly delete this e-mail and any attachment and all copies and inform the sender.
rohit.vohra | 22 Nov 2004 10:16
Favicon

Problem in executing a batch


Hi, 
 
I'm currently using IBatis version 2.0.3. I'm not able to work upon with Batch. I'm doing the following : 
 
sqlMap.startBatch(); 
sqlMap.insert(....); 
sqlMap.update(....); 
int rows = sqlMap.executeBatch(); 
System.out.println("Number of rows affected = "+rows); 
 
And it is always showing 0. 
 
I debugged and found that when executeBatch is being executed, following code snippet


   public int executeBatch(SessionScope session)
      throws SQLException {
    int rows = 0;
    Batch batch = (Batch) session.getBatch();
    if (batch != null) {
      try {
        rows = batch.executeBatch();
      } finally {
        batch.cleanupBatch();
      }
    }
    return rows;
  }        


        in SqlExecuter,  batch = (Batch) session.getBatch() always returns null. Please help me out with this.

Thanks,

Rohit Vohra
Tata Consultancy Services Limited
C - 56, Phase 2
Noida,Uttar Pradesh
India
Mailto: rohit.vohra <at> tcs.com
Website: http://www.tcs.com
DISCLAIMER: The information contained in this message is intended only and solely for the addressed individual or entity indicated in this message and for the exclusive use of the said addressed individual or entity indicated in this message (or responsible for delivery of the message to such person) and may contain legally privileged and confidential information belonging to Tata Consultancy Services Limited. It must not be printed, read, copied, disclosed, forwarded, distributed or used (in whatsoever manner) by any person other than the addressee. Unauthorized use, disclosure or copying is strictly prohibited and may constitute unlawful act and can possibly attract legal action, civil and/or criminal. The contents of this message need not necessarily reflect or endorse the views of Tata Consultancy Services limited on any subject matt er.
Any action taken or omitted to be taken based on this message is entirely at your risk and neither the originator of this message nor Tata Consultancy Services Limited takes any responsibility or liability towards the same. Opinions, conclusions and any other information contained in this message that do not relate to the official business of Tata Consultancy Services limited shall be understood as neither given nor endorsed by Tata Consultancy Services Limited or any affiliate of Tata Consultancy Services Limited. If you have received this message in error, you should destroy this message and may please notify the sender by e-mail.
Thank you.
Nilesh Bhattad | 24 Nov 2004 16:50

Generic SQL Map - sorry if this is a repost !

I created a generic SQL Map like below. I get a SQL stmt from somewhere and trying to use iBatis SQLMap just to execute the SQL. I'll provide the complete select stmt.

<select id="custom_sqlstmt" parameterClass="java.util.HashMap" resultClass="java.util.HashMap">

    $custom_sql$

</select>

First call goes thro and comes back with proper results. But when I try to execute a different SQL using this same SQL Map, it gives me some mapping exceptions. Looking at the exception, all I can think of is that, sql map internally keeps the resultset metadata's structure somewhere in the cache and use the same information again for the subsequent sql calls. In above case, since I provide a different SQL stmt each time, resultset metadata would be different per call. And as a result, when sqlmap tries to map the result using old structure, it throws mapping exceptions.

Is there any work around to resolve this issue? Thanks in advance for your help!

- Nilesh -

Aliaksandr Radzivanovich | 25 Nov 2004 11:56
Picon

Re: Custom property editor?

Thanks Kris, I've already found this class. My problem is that in some
cases it's a bit cumbersome to deal with type handlers in XML mapping
file.
It's not a problem for result maps, for example:
<resultMap id="personResult" class="person">
   <result property="birthDate" column="BirthDate" typeHandler="thDate"/>
Once described this result map can be used for any number of queries.
But to apply type handler to a parameter (not a result) I have to use
parameter map, or I have to specify
#parameterName,typeHandler=typeHandlerName#
for every mapped bean property like in the following example.
INSERT INTO Person (ID, …, BirthDate)
VALUES (#id#, …, #birthDate,typeHandler=thDate#)
When using parameter map it is impossible to use bean property names,
only their indices. So mapping and statement would look like
<parameterMap id="personParam" class="person">
   <parameter property="id"/>
   ...
   <parameter property="birthDate" typeHandler="thDate"/>
INSERT INTO Person (ID, …, BirthDate)
VALUES (?, …, ?)
Thus, for every single insert or update statement I have to provide
its own unique parameter map, or I have to specify type handler for
the same property in every update statement.
Am I right in my assumption?
So my suggestion is: it would be nice to create one general parameter
map and then using it with any number update statements providing bean
property names instead of their indices. Is this possible?
Your help will be appreciated.

Kris Jenkins | 25 Nov 2004 12:13
Picon
Favicon

Re: Custom property editor?

Aliaksandr Radzivanovich wrote:

>Thanks Kris, I've already found this class. My problem is that in some
>cases it's a bit cumbersome to deal with type handlers in XML mapping
>file.
>It's not a problem for result maps, for example:
><resultMap id="personResult" class="person">
>   <result property="birthDate" column="BirthDate" typeHandler="thDate"/>
>Once described this result map can be used for any number of queries.
>But to apply type handler to a parameter (not a result) I have to use
>parameter map, or I have to specify
>#parameterName,typeHandler=typeHandlerName#
>for every mapped bean property like in the following example.
>INSERT INTO Person (ID, …, BirthDate)
>VALUES (#id#, …, #birthDate,typeHandler=thDate#)
>When using parameter map it is impossible to use bean property names,
>only their indices. So mapping and statement would look like
><parameterMap id="personParam" class="person">
>   <parameter property="id"/>
>   ...
>   <parameter property="birthDate" typeHandler="thDate"/>
>INSERT INTO Person (ID, …, BirthDate)
>VALUES (?, …, ?)
>Thus, for every single insert or update statement I have to provide
>its own unique parameter map, or I have to specify type handler for
>the same property in every update statement.
>Am I right in my assumption?
>So my suggestion is: it would be nice to create one general parameter
>map and then using it with any number update statements providing bean
>property names instead of their indices. Is this possible?
>Your help will be appreciated.
>  
>

I believe you're right - you'll have to specify the typeHandler in every 
place that you use the property.

As for your suggestion, we'll have to farm this out to Clinton et. al., 
but it strikes me as messy.  Here's my alternative suggestion 
(shamelessly lifted from Spring 's Validator interface) - add a new 
method to TypeHandlerCallback:

    /** Returns true if this typehandler supports the given class. */
    boolean supports( Class clazz );

For a property with a non-standard javaType, SqlMap would transparently 
use the first registered TypeHandler that claims to support the 
property's class.
Perhaps SqlMap would consult these /before/ the standard typehandlers, 
which would give people the possibility of overriding the default 
handling, too.

Any thoughts, anybody?

--

-- 
Kris Jenkins
Email:  kris <at> jenkster.com
Blog:   http://cafe.jenkster.com/
Wiki:   http://wiki.jenkster.com/


Gmane