FW: ibatis and global transactions

2005-05-23 Thread James, Steven
 thanks brandon and rafiq. this is the route i will now explore. Ibatis 
is a fine product but the support on the forums here makes it something else.

top job.

Steve..


-Original Message-
From: Brandon Goodin [mailto:[EMAIL PROTECTED]
Sent: Fri 5/20/2005 6:33 PM
To: James, Steven
Subject: Re: ibatis and global transactions
 
I believe EXTERNAL would be the way for you to go. If you are making
changes against your database that are not completed all at once in a
single connection then you would have to devise a strategy outside of
ibatis to manage that.

Standard IBatis works something like this.

User Data passed to Biz Logic - Biz Logic calls dao(s) - sql is
prepared - connection is retrieved - operation is executed -
connection is closed - results are passed back to biz logic via dao
- data presented to user.

In your scenario you would need to retain the connection for the user
in order to prevent a commit. This would require that you manage you
own connection externally and pass them in to ibatis. You will also
need a way to manage your connections and identify them with the
users. But, i suspect you know how to do that.

Brandon



On 5/20/05, James, Steven [EMAIL PROTECTED] wrote:
 Thanks brandon.
 I think i may have used the term global transaction incorrectly.
 I really would like to have a unit or work start, end transaction that spans a
 number of business objects and can be rolled back at client request. I will 
 also only have one datasource.
 Also i do not use the ibatis daomanager i created a simple class that gets my 
 dao.
 
 If your original response is correct can i use jta without jndi.
 Again thanks for you help it is most appriciated.
 
 steve...
 
 -Original Message-
 From: Brandon Goodin [mailto:[EMAIL PROTECTED]
 Sent: Fri 5/20/2005 2:19 PM
 To: ibatis-user-java@incubator.apache.org
 Subject: Re: ibatis and global transactions
 
 You can manage your transactions with EXTERNAL of JTA. I believe that
 EXTERNAL is the better route to go in this case. This means that you
 will need to configure and manually start and stop your transactions
 outside of ibatis. Search the DAO pdf doc and the SQL Maps pdf doc for
 external to get more information.
 
 The JTA option in ibatis is tied to a single datasource. So, as far as
 global transactions that span databases... I don't think it would be
 that simple to accomplish with iBatis JTA support.
 
 Your other option is to use Spring (which would mean you get rid of
 the dao.xml) and setup sqlMapConfigs for each database you are
 accessing. Then you could use Spring's transaction management to
 manage transactions across any data access implementations you might
 have.
 
 Brandon
 
 On 5/20/05, James, Steven [EMAIL PROTECTED] wrote:
  Hi
 
  I working on an application where the services and buisness domain objects 
  are sitting on a server with ibatis providing the data access layer support.
  The clients which are swt client connect to the server and via rpc calls.
  Our customer want us to rollback all db changes during a user login should 
  they not want to commit (Commit in our case is not commit to db but to 
  cascade data changes to other machines) ie they want to undo the changes 
  made to the db ie rollback. Is ibatis capable of providing this global 
  transaction that spans a users session if you like.
 
  In the daomanager api there is talk of 2 phase commits but i dont think 
  this is the same thing?
 
  we are using mysql and the jdbc connector 3.1.6, the jdk is 1.4.2 no j2ee 
  application server.
 
  many thanks
 
  steve..
 
  This e-mail and any attachment is for authorised 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. Thank you.
 
 
 
 This e-mail and any attachment is for authorised 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. Thank you.




This e-mail and any attachment is for authorised 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. Thank you.


Merging multiple sqlmaps configurations

2005-05-23 Thread Zeltner Martin
Hello,

I've got following two sqlmaps configuration files:


file1:
sqlMapConfig
sqlMap resource=ibatis/table-keyword.xml /
/sqlMapConfig

file2:
sqlMapConfig
sqlMap resource=ibatis/table-annotation.xml /
sqlMap resource=ibatis/table-file.xml /
sqlMap resource=ibatis/table-link.xml /
sqlMap resource=ibatis/table-book.xml /
sqlMap resource=ibatis/table-formalpublication.xml /
sqlMap resource=ibatis/table-referencekeywordrelationship.xml /
/sqlMapConfig



I'd like to merge these two files now. Is there a possability so that I do
not have to create a file like this below?

file3:
sqlMapConfig
sqlMap resource=ibatis/table-keyword.xml /
sqlMap resource=ibatis/table-annotation.xml /
sqlMap resource=ibatis/table-file.xml /
sqlMap resource=ibatis/table-link.xml /
sqlMap resource=ibatis/table-book.xml /
sqlMap resource=ibatis/table-formalpublication.xml /
sqlMap resource=ibatis/table-referencekeywordrelationship.xml /
/sqlMapConfig


Thanks,
Cheers,
Martin


Re: Merging multiple sqlmaps configurations

2005-05-23 Thread Brandon Goodin
I'm really not sure what you are asking here. There is no way to
combine two different sqlMapConfig files into one. You would have to
create a new sqlMapConfig with all of the sqlMap files configured into
it or load two SqlMapClients with their own sqlMapConfig files.

Brandon

On 5/23/05, Zeltner Martin [EMAIL PROTECTED] wrote:
 Hello,
 
 I've got following two sqlmaps configuration files:
 
 
 file1:
 sqlMapConfig
 sqlMap resource=ibatis/table-keyword.xml /
 /sqlMapConfig
 
 file2:
 sqlMapConfig
 sqlMap resource=ibatis/table-annotation.xml /
 sqlMap resource=ibatis/table-file.xml /
 sqlMap resource=ibatis/table-link.xml /
 sqlMap resource=ibatis/table-book.xml /
 sqlMap resource=ibatis/table-formalpublication.xml /
 sqlMap resource=ibatis/table-referencekeywordrelationship.xml /
 /sqlMapConfig
 
 
 
 I'd like to merge these two files now. Is there a possability so that I do
 not have to create a file like this below?
 
 file3:
 sqlMapConfig
 sqlMap resource=ibatis/table-keyword.xml /
 sqlMap resource=ibatis/table-annotation.xml /
 sqlMap resource=ibatis/table-file.xml /
 sqlMap resource=ibatis/table-link.xml /
 sqlMap resource=ibatis/table-book.xml /
 sqlMap resource=ibatis/table-formalpublication.xml /
 sqlMap resource=ibatis/table-referencekeywordrelationship.xml /
 /sqlMapConfig
 
 
 Thanks,
 Cheers,
 Martin



Re: M:M question

2005-05-23 Thread Brandon Goodin
It's difficult to answer this question because i don't really know the
larger context. Usually i handle delete checkboxes and updates by
iterating my list of objects returned from the screen. As i iterate
through each object of the list i check to see if it is checked to be
deleted and place it into a delete list. If it is not flagged for a
delete i place it into an update list. Once i am finished iterating
the list i pass the delete list to a delete function and my update
list to an update function. Where you place this functionality in your
architecture is a matter of your own judgment.

Brandon

On 5/22/05, Sergey Livanov [EMAIL PROTECTED] wrote:
 
 Could you advise as to how to better solve the problem.
 There is th table M:M with the following structure
  CLASSFK number ,
  PROPERTY FK number ,
  QUANTITY number .
 
 In my application I define PROPERTY  QUANTITY for the CLASS class (with the
 help of checkbox ) upon which I need to record the information/results. If I
 choose checkbox - the record is to be deleted, if it is not there - it
 should be added, if it is there QUANTITY should be updated.
 
 --
 regards,
  Sergey  mailto:[EMAIL PROTECTED]
 



RE: Merging multiple sqlmaps configurations

2005-05-23 Thread Zeltner Martin
Hi,

I have two modules which are totally independent from each other. Each
module uses more then one resource configuration. I would like to be able to
create a new module, which has a dependency to the other two modules. This
new module should only know the main config file and not the
implementation details of the submodules. So we have only one entry point.

What I really want is to combine sets of sql resources.
This case is used in a framework for java.

Cheers,
Martin

-Original Message-
From: Brandon Goodin [mailto:[EMAIL PROTECTED]
Sent: Montag, 23. Mai 2005 14:26
To: ibatis-user-java@incubator.apache.org
Subject: Re: Merging multiple sqlmaps configurations


I'm really not sure what you are asking here. There is no way to
combine two different sqlMapConfig files into one. You would have to
create a new sqlMapConfig with all of the sqlMap files configured into
it or load two SqlMapClients with their own sqlMapConfig files.

Brandon

On 5/23/05, Zeltner Martin [EMAIL PROTECTED] wrote:
 Hello,
 
 I've got following two sqlmaps configuration files:
 
 
 file1:
 sqlMapConfig
 sqlMap resource=ibatis/table-keyword.xml /
 /sqlMapConfig
 
 file2:
 sqlMapConfig
 sqlMap resource=ibatis/table-annotation.xml /
 sqlMap resource=ibatis/table-file.xml /
 sqlMap resource=ibatis/table-link.xml /
 sqlMap resource=ibatis/table-book.xml /
 sqlMap resource=ibatis/table-formalpublication.xml /
 sqlMap resource=ibatis/table-referencekeywordrelationship.xml /
 /sqlMapConfig
 
 
 
 I'd like to merge these two files now. Is there a possability so that I do
 not have to create a file like this below?
 
 file3:
 sqlMapConfig
 sqlMap resource=ibatis/table-keyword.xml /
 sqlMap resource=ibatis/table-annotation.xml /
 sqlMap resource=ibatis/table-file.xml /
 sqlMap resource=ibatis/table-link.xml /
 sqlMap resource=ibatis/table-book.xml /
 sqlMap resource=ibatis/table-formalpublication.xml /
 sqlMap resource=ibatis/table-referencekeywordrelationship.xml /
 /sqlMapConfig
 
 
 Thanks,
 Cheers,
 Martin



null BLOB and byte array

2005-05-23 Thread Paul Barry
I have a BLOB column in my database that can be null.  I want to map it 
to a byte[], but when I do, I get a NullPointerException.  Anyway have a 
good way of dealing with this?


Re: [HELP] I can't not type sign in my sqlmap xml file

2005-05-23 Thread Huy

Brandon Goodin wrote:

This is just plain funny. Can you tell that we love the easy questions?

Brandon

On 5/19/05, Ron Grabowski [EMAIL PROTECTED] wrote:


You can use:

lt;



I find it funny that lt; and gt; are acceptable solutions (even though 
it works). I love sqlmap but I hate xml ! I wish sqlmap used something 
like velocity. There was discussion about this a while back anyone have 
any further information ?


Huy



Where are the test cases in the source download

2005-05-23 Thread Nathan Maves

Are these available anywhere?

Also I think the subversion repository on the web is not working.

Nathan


Re: null BLOB and byte array

2005-05-23 Thread Nathan Maves

Paul,

btye[] are objects so having them be null is just fine.

byte[] test = null;

I am not sure if there is a test case written for this yet.

I will look into it.

Nathan
On May 23, 2005, at 8:35 AM, Paul Barry wrote:

I have a BLOB column in my database that can be null.  I want to  
map it to a byte[], but when I do, I get a NullPointerException.   
Anyway have a good way of dealing with this?






Re: null BLOB and byte array

2005-05-23 Thread Paul Barry
If I change these methods in 
com.ibatis.sqlmap.engine.type.BlobTypeHandlerCallback, it works fine:


  public Object getResult(ResultGetter getter)
  throws SQLException {
Blob blob = getter.getBlob();
if(blob != null) {
int size = (int) blob.length();
return blob.getBytes(1, size);  
} else {
return null;
}

  }

  public void setParameter(ParameterSetter setter, Object parameter)
  throws SQLException {
if(parameter != null) {
byte[] bytes = (byte[]) parameter;
setter.setBytes(bytes);
}
  }

Nathan Maves wrote:

Paul,

btye[] are objects so having them be null is just fine.

byte[] test = null;

I am not sure if there is a test case written for this yet.

I will look into it.

Nathan
On May 23, 2005, at 8:35 AM, Paul Barry wrote:

I have a BLOB column in my database that can be null.  I want to  map 
it to a byte[], but when I do, I get a NullPointerException.   Anyway 
have a good way of dealing with this?






Re: Merging multiple sqlmaps configurations

2005-05-23 Thread Brandon Goodin
Sorry Martin, i have no idea what you are asking. Please be more
specific. It would be helpful if you clarified what a module is and
how it relates to sqlmap configurations. Does anyone else understand
Martin's problem? I'm known to be dense :)

Brandon

On 5/23/05, Zeltner Martin [EMAIL PROTECTED] wrote:
 Hi,
 
 I have two modules which are totally independent from each other. Each
 module uses more then one resource configuration. I would like to be able to
 create a new module, which has a dependency to the other two modules. This
 new module should only know the main config file and not the
 implementation details of the submodules. So we have only one entry point.
 
 What I really want is to combine sets of sql resources.
 This case is used in a framework for java.
 
 Cheers,
 Martin
 
 -Original Message-
 From: Brandon Goodin [mailto:[EMAIL PROTECTED]
 Sent: Montag, 23. Mai 2005 14:26
 To: ibatis-user-java@incubator.apache.org
 Subject: Re: Merging multiple sqlmaps configurations
 
 
 I'm really not sure what you are asking here. There is no way to
 combine two different sqlMapConfig files into one. You would have to
 create a new sqlMapConfig with all of the sqlMap files configured into
 it or load two SqlMapClients with their own sqlMapConfig files.
 
 Brandon
 
 On 5/23/05, Zeltner Martin [EMAIL PROTECTED] wrote:
  Hello,
 
  I've got following two sqlmaps configuration files:
 
 
  file1:
  sqlMapConfig
  sqlMap resource=ibatis/table-keyword.xml /
  /sqlMapConfig
 
  file2:
  sqlMapConfig
  sqlMap resource=ibatis/table-annotation.xml /
  sqlMap resource=ibatis/table-file.xml /
  sqlMap resource=ibatis/table-link.xml /
  sqlMap resource=ibatis/table-book.xml /
  sqlMap resource=ibatis/table-formalpublication.xml /
  sqlMap resource=ibatis/table-referencekeywordrelationship.xml /
  /sqlMapConfig
 
 
 
  I'd like to merge these two files now. Is there a possability so that I do
  not have to create a file like this below?
 
  file3:
  sqlMapConfig
  sqlMap resource=ibatis/table-keyword.xml /
  sqlMap resource=ibatis/table-annotation.xml /
  sqlMap resource=ibatis/table-file.xml /
  sqlMap resource=ibatis/table-link.xml /
  sqlMap resource=ibatis/table-book.xml /
  sqlMap resource=ibatis/table-formalpublication.xml /
  sqlMap resource=ibatis/table-referencekeywordrelationship.xml /
  /sqlMapConfig
 
 
  Thanks,
  Cheers,
  Martin
 



RE: Merging multiple sqlmaps configurations

2005-05-23 Thread Jean-Francois Poilpret
Well I think that Martin would like to be able to define separate
application modules (maybe packaged as separate independent jars), each
including each own SqlMaps config file. Then when assembling these modules
together in a complete application, there would be a problem building a
SqlMapClient from several SqlMap config files instead of only one.

Just my 2 cents.

-Original Message-
From: Brandon Goodin [mailto:[EMAIL PROTECTED] 
Sent: Monday, May 23, 2005 10:25 PM
To: ibatis-user-java@incubator.apache.org
Subject: Re: Merging multiple sqlmaps configurations

Sorry Martin, i have no idea what you are asking. Please be more
specific. It would be helpful if you clarified what a module is and
how it relates to sqlmap configurations. Does anyone else understand
Martin's problem? I'm known to be dense :)

Brandon

On 5/23/05, Zeltner Martin [EMAIL PROTECTED] wrote:
 Hi,
 
 I have two modules which are totally independent from each other. Each
 module uses more then one resource configuration. I would like to be able
to
 create a new module, which has a dependency to the other two modules. This
 new module should only know the main config file and not the
 implementation details of the submodules. So we have only one entry
point.
 
 What I really want is to combine sets of sql resources.
 This case is used in a framework for java.
 
 Cheers,
 Martin
 
 -Original Message-
 From: Brandon Goodin [mailto:[EMAIL PROTECTED]
 Sent: Montag, 23. Mai 2005 14:26
 To: ibatis-user-java@incubator.apache.org
 Subject: Re: Merging multiple sqlmaps configurations
 
 
 I'm really not sure what you are asking here. There is no way to
 combine two different sqlMapConfig files into one. You would have to
 create a new sqlMapConfig with all of the sqlMap files configured into
 it or load two SqlMapClients with their own sqlMapConfig files.
 
 Brandon
 
 On 5/23/05, Zeltner Martin [EMAIL PROTECTED] wrote:
  Hello,
 
  I've got following two sqlmaps configuration files:
 
 
  file1:
  sqlMapConfig
  sqlMap resource=ibatis/table-keyword.xml /
  /sqlMapConfig
 
  file2:
  sqlMapConfig
  sqlMap resource=ibatis/table-annotation.xml /
  sqlMap resource=ibatis/table-file.xml /
  sqlMap resource=ibatis/table-link.xml /
  sqlMap resource=ibatis/table-book.xml /
  sqlMap resource=ibatis/table-formalpublication.xml /
  sqlMap resource=ibatis/table-referencekeywordrelationship.xml /
  /sqlMapConfig
 
 
 
  I'd like to merge these two files now. Is there a possability so that I
do
  not have to create a file like this below?
 
  file3:
  sqlMapConfig
  sqlMap resource=ibatis/table-keyword.xml /
  sqlMap resource=ibatis/table-annotation.xml /
  sqlMap resource=ibatis/table-file.xml /
  sqlMap resource=ibatis/table-link.xml /
  sqlMap resource=ibatis/table-book.xml /
  sqlMap resource=ibatis/table-formalpublication.xml /
  sqlMap resource=ibatis/table-referencekeywordrelationship.xml /
  /sqlMapConfig
 
 
  Thanks,
  Cheers,
  Martin
 





Re: Where are the test cases in the source download

2005-05-23 Thread Larry Meadors
The tests are not in the download, only in SVN - trunk/java/mapper/mapper2/test

Larry

On 5/23/05, Nathan Maves [EMAIL PROTECTED] wrote:
 Are these available anywhere?
 
 Also I think the subversion repository on the web is not working.
 
 Nathan



Re: R: [New Feature] SQL Map Interface Binding -for your review

2005-05-23 Thread Clinton Begin
Thanks Fabrizio,

To clarify, yes, this is all completely optional functionality.

Cheers,
ClintonOn 5/23/05, Fabrizio Gianneschi [EMAIL PROTECTED] wrote:





I think this is a very **cool** new feature, but I would 
vote for it only if it's use is optional, or completely 
automated.

One of the reasons I like iBATIS is its 
simplicity;this solution complicates a bit the overall design, and it's a 
bit more hard to understand for a newbie. As Aitor already 
notes, there is the issue of the proliferation of interfaces. 
In addition, using the Object class as a parameter (and return type) 
makes the coding extremely fast, when you want to do so.

What about generating the interfaces from the sql map 
files? At least, generating part of them, when the I/O types are well 
known.

F


Da: Clinton Begin 
[mailto:[EMAIL PROTECTED]] Inviato: domenica 22 maggio 2005 
18.35A: ibatis-user-java@incubator.apache.orgOggetto: [New 
Feature] SQL Map Interface Binding -for your review
The dev list has already seen this. I 
just want to make sure anyone who doesn't subscribe to the dev list gets a 
chance to provide some 
feedback...-Although 
quite simple, there are some tradeoffs with the typical SqlMapClient methods 
like: Document doc = (Document) 
sqlMap.queryForObject(getDocument, new 
Integer (1));First of all, it is possible that you could spell 
getDocuments incorrectly. Second, the parameter is not strongly 
typed. So at code time, you could easily pass in an inappropriate 
object. Also, the return type is cast, so it's even possible for the 
statement to return an invalid object (i.e. result map returns a Dog instead of 
a Document). Finally, if you're using anything less than J2SE 5.0, you 
have to wrap primitives with their wrapper types. DISCLAIMER: Yes, 
you should have unit tests to verify this anyway! ;-)But what else can 
we do about this? Well, what if we mapped the getDocument mapped 
statement to an interface. For example, this one:public interface 
DocumentMapper {  Document getDocument (int id);}So 
basically we have a method that mirrors the queryForList signature, except the 
method name matches the mapped statement name, instead of passing it as a 
parameter. Furthermore, as soon as the SqlMapClient is built, this method 
is validated against the mapped statement to ensure that the proper parameter 
and result types are defined. Finally, using the sucker is a whole lot 
easier: Document doc = 
documentMapper.getDocument(1);No more casting. No more 
wrapping. No more ambiguous types. No more 
misspelling.Sounds good, how do I create a Mapper? Well, we 
already have. The interface above is all we need. A simple call to 
the following SqlMapClient method, creates the instance that can be 
used: DocumentMapper documentMapper = (DocumentMapper) 
sqlMap.getMapper(DocumentMapper.class);The instance is thread safe, so 
you can keep this sucker around as a field on your DAO or service 
class.Best of all, unit testing becomes a snap, as you can mock a 
DocumentMapper a heck of a lot easier than you could the SqlMapClient 
interface.Alrighty! So when will it be implemented? It already is. It's in SVN right now for 
your perusal, here's the unit test:
http://svn.apache.org/repos/asf/incubator/ibatis/trunk/java/mapper/mapper2/test/com/ibatis/sqlmap/BindingTest.java 
The JavaDoc is below.The current implementation isn't 
optimized, nor does it perform full validation. In it's current state, it's mostly intended to be 
easily removed if you don't like the idea.So let us know what you 
think!Cheers,Clinton
getMapperpublic java.lang.Object getMapper(java.lang.Classiface)

  Returns a generated implementation of a cusom mapper class as specified by 
  the method parameter. The generated implementation will run mapped statements 
  by matching the method name to the statement name. The mapped statement 
  elements determine how the statement is run as per the following: 
  
insert -- insert() 
update -- update() 
delete -- delete() 
select -- queryForObject, queryForList or queryForMap, as 
determined by signature (see below) 
procedure -- determined by method name (see below) How 
  select statements are run is determined by the method signature, as per the 
  following: 
  
Object methodName (Object param) -- queryForObject 
List methodName (Object param [, int skip, int max | , int pageSize]) -- 
queryForList 
Map methodName (Object param, String keyProp [,valueProp]) -- 
queryForMap How stored procedures are run is determined by the 
  method name, as per the following: 
  
insertX -- insert() 
createX -- insert() 
updateX -- update() 
saveX -- update() 
deleteX -- delete() 
removeX -- delete() 
selectX -- queryForXx() determined by method signature as above 
queryX -- queryForXx() determined by method signature as above 

Recommended practice / nested ResultMaps

2005-05-23 Thread Karen Koch
Given the following nested resultMap configuration with the child resultMap including a complex property that is part of the groupBy, how should the groupBy on that property be specified? I tried using the complex property name, and I tried qualifying the complex property name with the simple key-value sub-property -- neither worked properly.

resultMap id="distUsagesResult" class="distUsages" groupBy="distKey, entryDate" result property="distKey" column="DistKey"/ result property="entryDate" column="Date"/ result property="org" column="Org"/ result property="costCtr" column="CostCtr"/ result property="task" column="Task"/ result property="option" column="Option"/ result property="statisticList" resultMap="StatType.statisticResult"/
 /resultMap


resultMap id="statisticResult" class="statistic" groupBy="distKey, entryDate, statType"
!-- also triedresultMap id="statisticResult" class="statistic" groupBy="distKey, entryDate, statType.statTypeKey" -- result property="distKey" column="StatDistKey"/ result property="entryDate" column="StatEntryDate"/ result property="statType" column="StatTypeKey" select="getStatType"/ result property="numUnits" column="StatNumUnits"/ /resultMap

resultMap id="statTypeResult" class="statType" result property="statTypeKey" column="StatTypeKey"/ result property="statTypeID" column="StatTypeID"/ result property="statTypeDesc" column="StatTypeDesc"/ result property="measUnits" column="MeasUnits"/ result property="numDecPlaces" column="NumDecPlaces"/ result property="org" column="Org"/ result property="account" column="Account"/ result property="costCtr" column="CostCtr"/ result property="task" column="Task"/ result property="option" column="Option"/ /resultMap 
Thanks thanks thanks!

Karen

RE: Query performs differently in SQL Query Analyzer

2005-05-23 Thread Barnett, Brian W.
When you say iBatis is doing way more than just running SQL, when does it do
*way more*? Each time it encounters a new query? Just the first query it
processes after startup? Is the *way more* documented somewhere?

The SQL I run in Query Analyzer is exactly the same. I pulled it from the
logging, which I turned off after your suggestion, but did not see a
noticeable difference.

-Original Message-
From: Nathan Maves [mailto:[EMAIL PROTECTED] 
Sent: Monday, May 23, 2005 11:19 AM
To: ibatis-user-java@incubator.apache.org
Subject: Re: Query performs differently in SQL Query Analyzer


This truly sound like a sql problem.  Make sure that the sql that is  
generated by ibatis is what you run in your analyzer.

On a side note make sure that all logging is turned off for your  
application.  This is a huge performance hit if it is turned on for  
any part of your app.

Nathan

On May 23, 2005, at 10:53 AM, Barnett, Brian W. wrote:

 Yes, I did notice that subsequent times the exact same query performed 
 better. The problem is that in our app, a teacher is presented with
 a list
 of students in her class. She wants to run a report on each one.  
 Clicking on
 a student executes the query below but with a different student id.

 It takes over a minute each time she selects a new student. Is this
 because
 the query is not identical each time? It really does me no good that
 subsequent times the query runs better, because the teacher doesn't  
 need to
 run the same student more than once.

 Suggestions?

 -Original Message-
 From: Nathan Maves [mailto:[EMAIL PROTECTED]
 Sent: Monday, May 23, 2005 10:59 AM
 To: ibatis-user-java@incubator.apache.org
 Subject: Re: Query performs differently in SQL Query Analyzer


 I think this needs a FAQ :)

 This has been cover quite a few times.

 iBatis is doing way more then just running sql.  Make sure that to 
 truly test the performance of iBatis that you run the query multiple 
 times.  The initial run is creating many object and sets everything 
 up.  Check the speed of the second and third runs to see more accurate 
 results.

 Nathan

 On May 23, 2005, at 10:13 AM, Barnett, Brian W. wrote:


 I have a query that returns in 3 or 4 seconds when I run it in 
 Microsoft SQL Query Analyzer but takes over a minute to return when 
 run through iBATIS.
 Can anyone give me some clues as to what I should check?

 Here is the SQL Map stuff:

 resultMap id=student_profile_combined_result
 class=java.util.HashMap
 result property=abbrev column=abbrev 
 nullValue=null_string/
 result property=session column=session_name 
 nullValue=null_string/
 result property=display column=display 
 nullValue=null_string/
 result property=dateTested column=dateTested 
 nullValue=null_string/
 result property=proficiencyLevel
 column=proficiency_level
 nullValue=null_string/
 result property=theTestScore column=the_test_score
 nullValue=-999/
 result property=schoolScoreAvg column=schoolScoreAvg
 nullValue=-999/
 result property=distScoreAvg column=distScoreAvg
 nullValue=-999/
 result property=gradeLevelId column=grade_level_id
 nullValue=-999/
 result property=schoolName column=school_name
 nullValue=null_string/
 result property=assessmentId column=assessment_id
 nullValue=-999/
 result property=schoolRawAvg column=schoolRawAvg
 nullValue=-999/
 result property=distRawAvg column=distRawAvg
 nullValue=-999/
 result property=lowcut column=lowcut nullValue=-999/
 result property=highcut column=highcut  
 nullValue=-999/
 result property=prof column=prof nullValue=-999/
 result property=ppId column=pp_id nullValue=-999/
 result property=theRawPoints column=the_raw_points
 nullValue=-999/
 result property=scoreMethodId column=score_method_id
 nullValue=-999/
 result property=aboveStandard column=above_standard
 nullValue=-999/
 result property=schoolAboveStandard
 column=school_above_standard nullValue=-999/
 result property=districtAboveStandard
 column=district_above_standard nullValue=-999/
 result property=sessionId column=session_id
 nullValue=-999/
 result property=maxScore column=maxScore
 nullValue=-999/
 result property=minScore column=minScore
 nullValue=-999/
 /resultMap

 select id=getStudentProfileDataCombined
 resultMap=student_profile_combined_result
 parameterClass=java.util.HashMap
 $sql$
 /select

 Here is the query:

 SELECT a.abbrev, tsts.session_name, tsts.session_id, y.display, 
 ts.dateTested, ppl.proficiency_level, ts.test_score AS
 the_test_score,
 avs.schoolScoreAvg, avd.distScoreAvg, gr.grade_level_id,
 sc.school_name,
 a.assessment_id, avs.schoolRawAvg, avs.school_above_standard,
  avd.distRawAvg, avd.district_above_standard, pp.lowcut, pp.highcut,
 pp.prof, pp.pp_id, ts.test_raw_points AS the_raw_points,
 a.score_method_id,
  

Re: [HELP] I can't not type sign in my sqlmap xml file

2005-05-23 Thread Brandon Goodin
I don't plan on promoting any templating languages. It offloads the
burden to another layer. The dyanmic conditionals would get out of
hand. At that point it would be far easier to handle things in java.
The heirarchal nature of xml is of great importance to dynamic sql.
So, i still see it as being the easiest means to manage the SQL. If
you are using a template language you already violate the verasity of
your sql outside of ibatis. So, lt; is a minor issue IMO.

In version 3.0 one of our goals is to remove the dependency on the
configuration being solely XML and allow for java based configuraiton.
This would mean that the xml would be a way to implement the
configuration. XML will continue to be the primary supported means of
configuration because there are so many reasons to continue in this
direction versus other templating languages.

But, in the future if you so desire, it may be possible for you to
contribute something cool with velocity. Personally, I don't think
velocity would add value to the process.

Brandon

On 5/23/05, Huy [EMAIL PROTECTED] wrote:
 Brandon Goodin wrote:
  This is just plain funny. Can you tell that we love the easy questions?
 
  Brandon
 
  On 5/19/05, Ron Grabowski [EMAIL PROTECTED] wrote:
 
 You can use:
 
  lt;
 
 
 I find it funny that lt; and gt; are acceptable solutions (even though
 it works). I love sqlmap but I hate xml ! I wish sqlmap used something
 like velocity. There was discussion about this a while back anyone have
 any further information ?
 
 Huy
 



Re: Merging multiple sqlmaps configurations

2005-05-23 Thread Brandon Goodin
Then your best bet is to create a sqlmapconfig that binds all of your
sqlmaps together outside of the modules. The modules would then
contain only the sqlmap files themselves.

Brandon 

On 5/23/05, Jean-Francois Poilpret [EMAIL PROTECTED] wrote:
 Well I think that Martin would like to be able to define separate
 application modules (maybe packaged as separate independent jars), each
 including each own SqlMaps config file. Then when assembling these modules
 together in a complete application, there would be a problem building a
 SqlMapClient from several SqlMap config files instead of only one.
 
 Just my 2 cents.
 
 -Original Message-
 From: Brandon Goodin [mailto:[EMAIL PROTECTED]
 Sent: Monday, May 23, 2005 10:25 PM
 To: ibatis-user-java@incubator.apache.org
 Subject: Re: Merging multiple sqlmaps configurations
 
 Sorry Martin, i have no idea what you are asking. Please be more
 specific. It would be helpful if you clarified what a module is and
 how it relates to sqlmap configurations. Does anyone else understand
 Martin's problem? I'm known to be dense :)
 
 Brandon
 
 On 5/23/05, Zeltner Martin [EMAIL PROTECTED] wrote:
  Hi,
 
  I have two modules which are totally independent from each other. Each
  module uses more then one resource configuration. I would like to be able
 to
  create a new module, which has a dependency to the other two modules. This
  new module should only know the main config file and not the
  implementation details of the submodules. So we have only one entry
 point.
 
  What I really want is to combine sets of sql resources.
  This case is used in a framework for java.
 
  Cheers,
  Martin
 
  -Original Message-
  From: Brandon Goodin [mailto:[EMAIL PROTECTED]
  Sent: Montag, 23. Mai 2005 14:26
  To: ibatis-user-java@incubator.apache.org
  Subject: Re: Merging multiple sqlmaps configurations
 
 
  I'm really not sure what you are asking here. There is no way to
  combine two different sqlMapConfig files into one. You would have to
  create a new sqlMapConfig with all of the sqlMap files configured into
  it or load two SqlMapClients with their own sqlMapConfig files.
 
  Brandon
 
  On 5/23/05, Zeltner Martin [EMAIL PROTECTED] wrote:
   Hello,
  
   I've got following two sqlmaps configuration files:
  
  
   file1:
   sqlMapConfig
   sqlMap resource=ibatis/table-keyword.xml /
   /sqlMapConfig
  
   file2:
   sqlMapConfig
   sqlMap resource=ibatis/table-annotation.xml /
   sqlMap resource=ibatis/table-file.xml /
   sqlMap resource=ibatis/table-link.xml /
   sqlMap resource=ibatis/table-book.xml /
   sqlMap resource=ibatis/table-formalpublication.xml /
   sqlMap resource=ibatis/table-referencekeywordrelationship.xml /
   /sqlMapConfig
  
  
  
   I'd like to merge these two files now. Is there a possability so that I
 do
   not have to create a file like this below?
  
   file3:
   sqlMapConfig
   sqlMap resource=ibatis/table-keyword.xml /
   sqlMap resource=ibatis/table-annotation.xml /
   sqlMap resource=ibatis/table-file.xml /
   sqlMap resource=ibatis/table-link.xml /
   sqlMap resource=ibatis/table-book.xml /
   sqlMap resource=ibatis/table-formalpublication.xml /
   sqlMap resource=ibatis/table-referencekeywordrelationship.xml /
   /sqlMapConfig
  
  
   Thanks,
   Cheers,
   Martin
  
 
 
 



Re: database password

2005-05-23 Thread Brandon Goodin
There are several things you can do here. You could setup a datasource
that is configured via JNDI. Your datasource could draw it's
credentials from elsewhere. But, the prolbem is that your credentials
have to be store somewhere. So, the question really winds up being...
where is a safe place to store your credentials? You could simply
configure the datasource with JNDI on the container level and place
the password there ouside of the deployed web application.

Brandon

On 5/23/05, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
 Hi,
 
 Database password is quite sensitive information and providing this in plain 
 file is not an option for us.
 Is there any way to set password programmatically?
 
 Or another scenario when password is changing often...
 
 Alex



Re: Query performs differently in SQL Query Analyzer

2005-05-23 Thread Clinton Begin


Each time it encounters a new query?

Let's define new query:

SELECT * FROM STUDENT WHERE STUDENT_ID = #id#

That's one query, regardless of what parameter you use for ?. In iBATIS, this is represented as:

But if you have any dynamic parts to the SQL or any $substitutions$, then you are potentially creating a new query. 

Regardless, there is NOTHING iBATIS does that should take a minute or longer, especially after initial runs.

You'll need to provide us with a lot more detail and do some of your own profiling to test out your situation properly.

First of all, DO NOT compare iBATIS with queries run from Query
Analyzerthat's ridiculous. You've eliminated more than iBATIS
in that scenario, you've also eliminated the network, JDBC, the driver
and all of your own Java code. 

My first questions would be: where and when do you build your
SqlMapClient instance? how often are you connecting? which
datasource are you using? do you have any dynamic SQL? are
you using maps or beans? are you using lazy loading, join
fetching, complex colum mapping via select= (N+1 selects problem)?

Performance problems are hard to diagnose properly. Can you give us any more information?

Clinton
On 5/23/05, Barnett, Brian W. [EMAIL PROTECTED] wrote:
When you say iBatis is doing way more than just running SQL, when does it do*way more*? Each time it encounters a new query? Just the first query itprocesses after startup? Is the *way more* documented somewhere?
The SQL I run in Query Analyzer is exactly the same. I pulled it from thelogging, which I turned off after your suggestion, but did not see anoticeable difference.-Original Message-From: Nathan Maves [mailto:
[EMAIL PROTECTED]]Sent: Monday, May 23, 2005 11:19 AMTo: ibatis-user-java@incubator.apache.orgSubject: Re: Query performs differently in SQL Query Analyzer
This truly sound like a sql problem.Make sure that the sql that isgenerated by ibatis is what you run in your analyzer.On a side note make sure that all logging is turned off for yourapplication.This is a huge performance hit if it is turned on for
any part of your app.NathanOn May 23, 2005, at 10:53 AM, Barnett, Brian W. wrote: Yes, I did notice that subsequent times the exact same query performed better. The problem is that in our app, a teacher is presented with
 a list of students in her class. She wants to run a report on each one. Clicking on a student executes the query below but with a different student id. It takes over a minute each time she selects a new student. Is this
 because the query is not identical each time? It really does me no good that subsequent times the query runs better, because the teacher doesn't need to run the same student more than once.
 Suggestions? -Original Message- From: Nathan Maves [mailto:[EMAIL PROTECTED]] Sent: Monday, May 23, 2005 10:59 AM To: 
ibatis-user-java@incubator.apache.org Subject: Re: Query performs differently in SQL Query Analyzer I think this needs a FAQ :)
 This has been cover quite a few times. iBatis is doing way more then just running sql.Make sure that to truly test the performance of iBatis that you run the query multiple times.The initial run is creating many object and sets everything
 up.Check the speed of the second and third runs to see more accurate results. Nathan On May 23, 2005, at 10:13 AM, Barnett, Brian W. wrote: I have a query that returns in 3 or 4 seconds when I run it in
 Microsoft SQL Query Analyzer but takes over a minute to return when run through iBATIS. Can anyone give me some clues as to what I should check? Here is the SQL Map stuff:
 resultMap id=student_profile_combined_result class=java.util.HashMap result property=abbrev column=abbrev
 nullValue=null_string/ result property=session column=session_name nullValue=null_string/ result property=display column=display
 nullValue=null_string/ result property=dateTested column=dateTested nullValue=null_string/ result property=proficiencyLevel
 column=proficiency_level nullValue=null_string/ result property=theTestScore column=the_test_score nullValue=-999/
 result property=schoolScoreAvg column=schoolScoreAvg nullValue=-999/ result property=distScoreAvg column=distScoreAvg
 nullValue=-999/ result property=gradeLevelId column=grade_level_id nullValue=-999/ result property=schoolName column=school_name
 nullValue=null_string/ result property=assessmentId column=assessment_id nullValue=-999/ result property=schoolRawAvg column=schoolRawAvg
 nullValue=-999/ result property=distRawAvg column=distRawAvg nullValue=-999/ result property=lowcut column=lowcut nullValue=-999/
 result property=highcut column=highcut nullValue=-999/ result property=prof column=prof nullValue=-999/
 result property=ppId column=pp_id nullValue=-999/ result property=theRawPoints column=the_raw_points nullValue=-999/
 result property=scoreMethodId column=score_method_id nullValue=-999/ result property=aboveStandard column=above_standard
 nullValue=-999/ result property=schoolAboveStandard 

RE: Query performs differently in SQL Query Analyzer [SOLVED]

2005-05-23 Thread Barnett, Brian W.
Title: Message



I 
decided to attempt to eliminate the items that Clinton had mentioned were 
outside the iBATIS framework (network, JDBC, driver). I started by swapping out 
the Microsoft JDBC driver with the jTDS JDBC driver for SQL Server (http://jtds.sourceforge.net/) and that 
fixed the performance problem with this particular query... woo 
ho!!!

We 
have yet to do complete testing throughout the rest of the application, but we 
are hopeful that all other queries will perform at least as well as they did 
with the Microsoft driver.

Thank 
you all for your input.

Brian 
Barnett

  
  -Original Message-From: Barnett, Brian 
  W. Sent: Monday, May 23, 2005 2:19 PMTo: 
  'ibatis-user-java@incubator.apache.org'Subject: RE: Query performs 
  differently in SQL Query Analyzer
  where and when do you build 
  your SqlMapClient instance? We used JPetStore 4 as a model for using 
  iBATIS. We have a DaoManager singleton that gets created during app startup. 
  dao.xml and sql-map-config.xml files are parsed and the DaoManager 
  caches instances of our daos.
  
  how often are you 
  connecting?Not sure how to answer this.
  
  which datasource are you 
  using?Snippet from sql-map-configsqlMapConfig
  
  settingscacheModelsEnabled="true"enhancementEnabled="true"lazyLoadingEnabled="true"useStatementNamespaces="false"maxSessions="128"maxTransactions="32"maxRequests="512"/
  
  transactionManager 
  type="JDBC"dataSource 
  type="JNDI"property name="DataSource" 
  value="java:comp/env/bppool"//dataSource/transactionManager
  
  are you using lazy 
  loading?Yes
  
  join fetching?Don't 
  know
  
   complex column mapping via 
  select="" (N+1 selects problem)?No
  
  Here is some additional 
  information:1.We run many, many queries through our web app and none 
  of the others exhibit this behavior.2.The performance problem is not 
  seen on smaller databases. (smaller number of rows in tables.)3.The 
  following line of code takes 55 seconds to executea.return 
  executeQueryForList("getStudentProfileDataCombined", 
  paramMap);b.Where paramMap has one entry called "sql" which contains 
  the SQL statement.4.Subsequent calls to the above line of code for 
  the same student come back in 1 second.5.We're running 2.0.0 RC5 
  Build 274.
  

-Original Message-From: Clinton Begin 
[mailto:[EMAIL PROTECTED] Sent: Monday, May 23, 2005 12:30 
PMTo: ibatis-user-java@incubator.apache.orgSubject: 
Re: Query performs differently in SQL Query 
AnalyzerEach time it encounters a new 
query?Let's define new query:SELECT * FROM STUDENT WHERE 
STUDENT_ID = #id#That's one query, regardless of what parameter you 
use for ?. In iBATIS, this is represented as:But if you have 
any dynamic parts to the SQL or any $substitutions$, then you are 
potentially creating a new query. Regardless, there is NOTHING 
iBATIS does that should take a minute or longer, especially after initial 
runs.You'll need to provide us with a lot more detail and do some of 
your own profiling to test out your situation properly.First of all, 
DO NOT compare iBATIS with queries run from Query Analyzerthat's 
ridiculous. You've eliminated more than iBATIS in that scenario, 
you've also eliminated the network, JDBC, the driver and all of your own 
Java code. My first questions would be: where and when 
do you build your SqlMapClient instance? how often are you 
connecting? which datasource are you using? do you have any 
dynamic SQL? are you using maps or beans? are you using lazy 
loading, join fetching, complex colum mapping via select="" (N+1 selects 
problem)?Performance problems are hard to diagnose properly. 
Can you give us any more information?Clinton
On 5/23/05, Barnett, 
Brian W. [EMAIL PROTECTED] 
wrote: 
When 
  you say iBatis is doing way more than just running SQL, when does it 
  do*way more*? Each time it encounters a new query? Just the first 
  query itprocesses after startup? Is the *way more* documented 
  somewhere?The SQL I run in Query Analyzer is exactly the same. I 
  pulled it from thelogging, which I turned off after your suggestion, 
  but did not see anoticeable difference.-Original 
  Message-From: Nathan Maves [mailto: [EMAIL PROTECTED]]Sent: 
  Monday, May 23, 2005 11:19 AMTo: ibatis-user-java@incubator.apache.orgSubject: 
  Re: Query performs differently in SQL Query Analyzer This 
  truly sound like a sql problem.Make sure that the sql that 
  isgenerated by ibatis is what you run in your analyzer.On a 
  side note make sure that all logging is turned off for 
  yourapplication.This is a huge performance hit if it is 
  turned on for any part of your app.NathanOn May 23, 
  2005, at 10:53 AM, Barnett, Brian W. wrote: Yes, I did notice 
  that subsequent times the exact same query performed better. The 
  problem 

Re: complex inserts?

2005-05-23 Thread Larry Meadors
That all sounds like logic for your DAO or business layer. 

SQL maps are more fine-grained that that.

Larry


On 5/23/05, Lieven De Keyzer [EMAIL PROTECTED] wrote:
 In fact, it's even complexer than this, because when a certain notification
 is given as parameter and it is not present yet, is should be inserted, when
 it is present, nothing should happen, and when it's not given as parameter,
 it should be deleted.


Re: Feature Request

2005-05-23 Thread Brandon Goodin
SqlMapClientBuilder takes a reader. If you have a String in memory
then why couldn't you use a StringReader?

Brandon

On 5/23/05, Rob Butler [EMAIL PROTECTED] wrote:
 Hello,
 
 I am building an application that will need to
 dynamically build an SQL statement at run time, and
 then populate the statement's fields from a map.
 Sounds perfect for iBatis, right.  That's what I
 thought, but I don't think iBatis does quite what I
 need.  Normally iBatis can dynamically change it's SQL
 but you need to know things like the number, name 
 type of columns in advance when the SqlMap is created.
 
 Unfortunately in my application, the SQL statement
 that is built at runtime is completely dynamic.  The
 name of the columns, their data types and the number
 of columns will only be known at run time.  So what I
 would like to do is dynamically instantiate an
 SqlMapClient from a String, which contains the SqlMap
 that is dynamically generated at run time.  Then let
 iBatis do the work of converting the map's values into
 the correct data types and populating the SQL's field
 values.  It would be nice if the table name could be
 passed as a property instead of in the map of data.
 
 This looks like it would be possible with the
 SqlMapClientBuilder, but I don't think that is going
 to work.  The problem is it wants to read an
 SqlMapConfig, which then of course points to an SqlMap
 file.  However, the SqlMap file obviously won't exist
 anywhere but as a string in ram, and it's not possible
 (as far as I know) to directly load an SqlMap using
 SqlMapClientBuilder, nor is it possible to load a
 single file (string in ram) that is a combined
 SqlMapConfig  SqlMap.
 
 I could probably cobble something together using the
 internal non-user exposed classes within iBatis, but
 then if those classes change from one release to the
 next I would have to make the appropriate changes to
 my code, and I would prefer to use something that is
 part of iBatis.
 
 So, I would like to request a feature to make
 dynamically building the SqlMap at runtime possible.
 I suppose this could be done by developing a class
 like SqlMapClientBuilder that accepted a String, and
 didn't need an SqlMapConfig, just a SqlMap XML.
 Alternately, a fixed API could be exposed to users to
 manually construct a SqlClientMap.
 
 Thoughts?  Is there a better approach that works now?
 Did I miss something obvious?
 
 Thanks, and iBatis rocks!
 Rob
 
 
 
 __
 Do you Yahoo!?
 Yahoo! Small Business - Try our new Resources site
 http://smallbusiness.yahoo.com/resources/



Re: Feature Request

2005-05-23 Thread j-lists
I've solved this one before by generating a temp file, grabbing the
absolute path, turning it into a url, assigning that to a property
with the key MAP_FILE and then putting this in my main config:
sqlMap url=${MAP_FILE}/

Which resolves to:
sqlMap url=file://localhost/tmp/ibatis345875.xml/

Or some such thing (the localhost bit seems to be required for windows
but not for Unix flavours).

Nice thing about this is that the generated file on disk is easy to
debug, just log out the temp file location after generating it.


Re: complex inserts?

2005-05-23 Thread Lieven De Keyzer



From: Larry Meadors [EMAIL PROTECTED]
Reply-To: [EMAIL PROTECTED]
To: ibatis-user-java@incubator.apache.org
Subject: Re: complex inserts?
Date: Mon, 23 May 2005 21:50:01 -0600

That all sounds like logic for your DAO or business layer.

SQL maps are more fine-grained that that.

Larry


On 5/23/05, Lieven De Keyzer [EMAIL PROTECTED] wrote:
 In fact, it's even complexer than this, because when a certain 
notification
 is given as parameter and it is not present yet, is should be inserted, 
when
 it is present, nothing should happen, and when it's not given as 
parameter,

 it should be deleted.


Hmm, I see. But these notificationWays belong to a Bookmark I think. So I 
should make these kind of test in the DAO layer. And make separate insert 
etc. statements for the bookmark table and for the notifications table?


But is it ok, to do something like:

updateBookmark(Bookmark){
   update(updateBookmark, bookmark);

   List notif = queryForList(getNotificationsByBookmark, bookmark);

   //perform various tests to see which notifications are already present 
and wich are not.

   //insert some notifications, update some and delete some

}