Re: Question on dynamic Select Columns

2005-05-27 Thread Brandon Goodin
Hey Ritu,

The dynamic tags examine the parameterMap or parameterClass not the
resultMap. Also, since your select results will potentially differ you
will need to set the remapResults=true attribute in the select.

Brandon

On 5/27/05, Ritu Kedia [EMAIL PROTECTED] wrote:
  
  
 
 Hello All, 
 
   
 
 This is my first post to IBatis. We are planning to use IBatis as our
 OR-Mapping tool. 
 
   
 
 First of all thanks to all the contributors for this great contribution. I
 particularly liked the dynamic SQl feature. 
 
   
 
 I have a question on whether the select columns can also be made dynamic?
 Currently I am getting SQLException for Invalid Column Name when the
 framework is trying to map the fetched data to the declared Result Map. 
 
   
 
 OR Could we bind the ResultMap dynamically to the Select statement? In other
 words could we have something like: 
 
   select id=FindDynamic resultMap=$resultMap$ 
 
 SELECT  ID, 
 
 NAME 
 
 dynamic prepend=, 
 
   isNotNull property=fetchDetails 
 
 DESCRIPTION, 
 
   /isNotNull 
 
 /dynamic 
 
 FROM  SOME_TABLE 
 
 dynamic prepend=WHERE 
 
   isNotNull prepend=AND property=name 
 
 NAME $name_operator$ #name# 
 
   /isNotNull 
 
   isNotNull prepend=AND property=description 
 
 DESCRIPTION $description_operator$ #description# 
 
   /isNotNull 
 
 /dynamic
 
   /select 
 
 Where $resultMap$ would be passed via the Java API. 
 
   
 
 If the resultMap is hard bound to the following: 
 
   resultMap id=Detail_ResultMap class=Some_Detail 
 
 result property=name column=Name/ 
 
 result property=description column=Description/ 
 
 result property=id column=ID/ 
 
   /resultMap 
 
   
 
 In the above select if the resultMap=Detail_ResultMap then when property
 fetchDetails is not present then I get a SQLException Invalid Column
 Name for the Description column. 
 
   
 
 Could someone please suggest a way to accommodate the above requirement of
 having dynamic select columns? 
 
   
 
 Thanks and Regards, 
 
 Ritu Kedia


Namespace Problem

2005-05-27 Thread Carson Reinke
Hi-

Not sure if this is the right mail list, but having a little trouble
using the namespace in the SQL map.  I have something like this in a
resultMap:

result property=someProperty column=DB_COLUMN
select=SomeNamespace.statementId/

I receive this error when trying to query:

--- The error occurred in iBATIS/sqlmap-XXX.xml.  
--- The error occurred while applying a result map.  
--- Check the XXX.XXX.  
--- Check the result mapping for the 'someProperty' property.  
--- Cause: com.ibatis.sqlmap.client.SqlMapException: There is no
statement named SomeNamespace.statementId in this SqlMap.]; SQL was []
for task [SqlMapClient operation]

Any ideas?  I the SQL maps doc said that was allowed.

Thanks.

Carson Reinke
[EMAIL PROTECTED]
P: 248.333.7700 x108  


Re: Namespace Problem

2005-05-27 Thread Daniel Henrique Ferreira e Silva
Hi Carson,

Did you enable namespaces in your sql-map-config?
Did you declare a valid namespace for your maps file?

Cheers,
Daniel Silva.

On 5/27/05, Carson Reinke [EMAIL PROTECTED] wrote:
 Hi-
 
 Not sure if this is the right mail list, but having a little trouble
 using the namespace in the SQL map.  I have something like this in a
 resultMap:
 
 result property=someProperty column=DB_COLUMN
 select=SomeNamespace.statementId/
 
 I receive this error when trying to query:
 
 --- The error occurred in iBATIS/sqlmap-XXX.xml.
 --- The error occurred while applying a result map.
 --- Check the XXX.XXX.
 --- Check the result mapping for the 'someProperty' property.
 --- Cause: com.ibatis.sqlmap.client.SqlMapException: There is no
 statement named SomeNamespace.statementId in this SqlMap.]; SQL was []
 for task [SqlMapClient operation]
 
 Any ideas?  I the SQL maps doc said that was allowed.
 
 Thanks.
 
 Carson Reinke
 [EMAIL PROTECTED]
 P: 248.333.7700 x108



RE: Namespace Problem

2005-05-27 Thread Carson Reinke
So I have to declare this in my sqlmap-config:

settings useStatementNamespaces=true/

This forces me to use namespaces whenever I reference a statement,
right?

I declared a namespace like this: sqlMap namespace=SomeNamespace,
are there any special rules with the naming?

Thanks.

Carson Reinke
[EMAIL PROTECTED]
P: 248.333.7700 x108  

-Original Message-
From: Daniel Henrique Ferreira e Silva [mailto:[EMAIL PROTECTED] 
Sent: Friday, May 27, 2005 1:35 PM
To: ibatis-user-java@incubator.apache.org
Subject: Re: Namespace Problem


Hi Carson,

Did you enable namespaces in your sql-map-config?
Did you declare a valid namespace for your maps file?

Cheers,
Daniel Silva.

On 5/27/05, Carson Reinke [EMAIL PROTECTED] wrote:
 Hi-
 
 Not sure if this is the right mail list, but having a little trouble 
 using the namespace in the SQL map.  I have something like this in a
 resultMap:
 
 result property=someProperty column=DB_COLUMN 
 select=SomeNamespace.statementId/
 
 I receive this error when trying to query:
 
 --- The error occurred in iBATIS/sqlmap-XXX.xml.
 --- The error occurred while applying a result map.
 --- Check the XXX.XXX.
 --- Check the result mapping for the 'someProperty' property.
 --- Cause: com.ibatis.sqlmap.client.SqlMapException: There is no 
 statement named SomeNamespace.statementId in this SqlMap.]; SQL was []

 for task [SqlMapClient operation]
 
 Any ideas?  I the SQL maps doc said that was allowed.
 
 Thanks.
 
 Carson Reinke
 [EMAIL PROTECTED]
 P: 248.333.7700 x108



RE: Namespace Problem

2005-05-27 Thread Carson Reinke
To answer my own questions, the settings
useStatementNamespaces=true/ works and I now reference all statements
with the namespace.  Thanks for the help!

Thanks.

Carson Reinke
[EMAIL PROTECTED]
P: 248.333.7700 x108  

-Original Message-
From: Carson Reinke 
Sent: Friday, May 27, 2005 1:43 PM
To: 'ibatis-user-java@incubator.apache.org'; 'Daniel Henrique Ferreira e
Silva'
Subject: RE: Namespace Problem


So I have to declare this in my sqlmap-config:

settings useStatementNamespaces=true/

This forces me to use namespaces whenever I reference a statement,
right?

I declared a namespace like this: sqlMap namespace=SomeNamespace,
are there any special rules with the naming?

Thanks.

Carson Reinke
[EMAIL PROTECTED]
P: 248.333.7700 x108  

-Original Message-
From: Daniel Henrique Ferreira e Silva [mailto:[EMAIL PROTECTED] 
Sent: Friday, May 27, 2005 1:35 PM
To: ibatis-user-java@incubator.apache.org
Subject: Re: Namespace Problem


Hi Carson,

Did you enable namespaces in your sql-map-config?
Did you declare a valid namespace for your maps file?

Cheers,
Daniel Silva.

On 5/27/05, Carson Reinke [EMAIL PROTECTED] wrote:
 Hi-
 
 Not sure if this is the right mail list, but having a little trouble
 using the namespace in the SQL map.  I have something like this in a
 resultMap:
 
 result property=someProperty column=DB_COLUMN
 select=SomeNamespace.statementId/
 
 I receive this error when trying to query:
 
 --- The error occurred in iBATIS/sqlmap-XXX.xml.
 --- The error occurred while applying a result map.
 --- Check the XXX.XXX.
 --- Check the result mapping for the 'someProperty' property.
 --- Cause: com.ibatis.sqlmap.client.SqlMapException: There is no
 statement named SomeNamespace.statementId in this SqlMap.]; SQL was []

 for task [SqlMapClient operation]
 
 Any ideas?  I the SQL maps doc said that was allowed.
 
 Thanks.
 
 Carson Reinke
 [EMAIL PROTECTED]
 P: 248.333.7700 x108



Support for generics

2005-05-27 Thread Nathan Maves
Since apple is taking then sweet time I just got Java 1.5.  I am  
diving in head first but I am curious about what the plans for  
Generics are.


Will I batis support them?
Could there be a way to specify the list type instead of Object?

i.e.
return a ListStudent back based on the result class of the query?

Nathan



Re: Support for generics

2005-05-27 Thread Brandon Goodin
This is definitely on our list to do... sometime :-p. But, it is a
matter of compatibility. We have talked about creating a special
ibatis version to take advantage of some of the java 5 features. But,
we haven't really looked into it real deep and don't know what it
would take to accomplish it and if it is something we need to add to
ibatis.

Have you tried to simply use generics with ibatis?

Brandon

On 5/27/05, Nathan Maves [EMAIL PROTECTED] wrote:
 Since apple is taking then sweet time I just got Java 1.5.  I am
 diving in head first but I am curious about what the plans for
 Generics are.
 
 Will I batis support them?
 Could there be a way to specify the list type instead of Object?
 
 i.e.
 return a ListStudent back based on the result class of the query?
 
 Nathan
 



Re: Support for generics

2005-05-27 Thread Larry Meadors
I have done that with my DAO layer. 

SqlMap returns it as List, but you can cast it.

Worked great. :)

Larry


On 5/27/05, Nathan Maves [EMAIL PROTECTED] wrote:
 Since apple is taking then sweet time I just got Java 1.5.  I am
 diving in head first but I am curious about what the plans for
 Generics are.
 
 Will I batis support them?
 Could there be a way to specify the list type instead of Object?
 
 i.e.
 return a ListStudent back based on the result class of the query?
 
 Nathan
 



Re: Support for generics

2005-05-27 Thread Brandon Goodin
Possibly the new early binding functionality (in the TRUNK) will allow
for you to use generic typing for your lists then you wouldn't need to
cast them. But, that is an untested suggestion.

Brandon

On 5/27/05, Larry Meadors [EMAIL PROTECTED] wrote:
 I have done that with my DAO layer.
 
 SqlMap returns it as List, but you can cast it.
 
 Worked great. :)
 
 Larry
 
 
 On 5/27/05, Nathan Maves [EMAIL PROTECTED] wrote:
  Since apple is taking then sweet time I just got Java 1.5.  I am
  diving in head first but I am curious about what the plans for
  Generics are.
 
  Will I batis support them?
  Could there be a way to specify the list type instead of Object?
 
  i.e.
  return a ListStudent back based on the result class of the query?
 
  Nathan
 
 



Re: Support for generics

2005-05-27 Thread Nathan Maves
Yeah, I have used generics everywhere but the missing link is when it  
gets to the DAO layer.


You can cast the List but you will always get the warning for and  
unchecked assignment when the List is returned from the sqlmap.


ListStudent students = (ListStudent)executeQueryForList 
(getStudents,null);


Looks good but does not resolve the warnings.

Nathan


On May 27, 2005, at 2:30 PM, Larry Meadors wrote:


I have done that with my DAO layer.

SqlMap returns it as List, but you can cast it.

Worked great. :)

Larry


On 5/27/05, Nathan Maves [EMAIL PROTECTED] wrote:


Since apple is taking then sweet time I just got Java 1.5.  I am
diving in head first but I am curious about what the plans for
Generics are.

Will I batis support them?
Could there be a way to specify the list type instead of Object?

i.e.
return a ListStudent back based on the result class of the query?

Nathan








Re: Querying Based on Date.

2005-05-27 Thread Brandon Goodin
What is the driver and database (include version) are you using? What
is the column type in the database?

Brandon

On 5/27/05, Cruz, Edward J. [EMAIL PROTECTED] wrote:
 I am having trouble with a query based on a date property.  Basically I need
 to return data where a Transaction_Date in the database is equal to a date I
 pass in through an object to the Ibatis framework.  The database holds
 Transaction_Date as a Date type and my parameter object also has a
 java.util.Date type.  I created a Date using the java SimpleDateFormat as
 follows.
 
 SimpleDateFormat date = new SimpleDateFormat(MMdd);
 Date transactionDate = date.parse(20040205);
 
 I used DbUnit to insert the transactionDate into the database.  Then I
 called the iBatis framework passing in an Transfer Object that holds
 transactionDate and has the appropriate getters and setters.
 
 My xml is as follows
 searchCriteria has the appropriate type alias.
 
 select id=queryForTotalRecords parameterClass=searchCriteria
 resultsClass=java.lang.Integer
 Select count(*) from orders
 dynamic prepend=where
 isNotNull prepend=AND property=transactionDate
 TRANSACTION_NUM = #transactionDate:date#
 /isNotNull
 /dynamic
 /select
   I have other properties that are all strings and work well in the same
 manner using isNotNull that is why I have the prepend=AND above.
 
 When looking at the log file when this runs it shows the following
 PreparedStatement: select count(*) from orders where TRANSACTION_NUM = ?
 Parameters: [2004-02-05 00:00:00.0]
 Types: [java.sql.Timestamp]
 
 The results of invoking this query when the same Date is entered into the
 database is 0.  When it should return 1.  Is there something special that
 needs to be done to compare Dates?  I even tried using both greater than and
 less than operators and I always receive 0 as my count.  Any Suggestions
 would be appreciated.
 
 
 Jamie Cruz
 Software Engineering
 [EMAIL PROTECTED]
 
 
 
 



Re: Support for generics

2005-05-27 Thread Clinton Begin

I believe the new Mapper binding functionality would resolve this

Nathan, are you up for trying it out?

Cheers,
Clinton
On 5/27/05, Nathan Maves [EMAIL PROTECTED] wrote:
Yeah, I have used generics everywhere but the missing link is when itgets to the DAO layer.You can cast the List but you will always get the warning for andunchecked assignment when the List is returned from the sqlmap.
ListStudent students = (ListStudent)executeQueryForList(getStudents,null);Looks good but does not resolve the warnings.NathanOn May 27, 2005, at 2:30 PM, Larry Meadors wrote:
 I have done that with my DAO layer. SqlMap returns it as List, but you can cast it. Worked great. :) Larry On 5/27/05, Nathan Maves 
[EMAIL PROTECTED] wrote: Since apple is taking then sweet time I just got Java 1.5.I am diving in head first but I am curious about what the plans for
 Generics are. Will I batis support them? Could there be a way to specify the list type instead of Object? i.e. return a ListStudent back based on the result class of the query?
 Nathan


Re: Support for generics

2005-05-27 Thread Nathan Maves
Of course!

Do I need to build it from the trunk?

Nathan

On May 27, 2005, at 8:32 PM, Clinton Begin wrote:

I believe the new Mapper binding functionality would resolve this

Nathan, are you up for trying it out?

Cheers,
Clinton


On 5/27/05, Nathan Maves [EMAIL PROTECTED]> wrote:
gets to the DAO layer.

You can cast the List but you will always get the warning for and
unchecked assignment when the List is returned from the sqlmap. 

ListStudent> students = (ListStudent>)executeQueryForList
(getStudents,null);

Looks good but does not resolve the warnings.

Nathan


On May 27, 2005, at 2:30 PM, Larry Meadors wrote: 

> I have done that with my DAO layer.
>
> SqlMap returns it as List, but you can cast it.
>
> Worked great. :)
>
> Larry
>
>
> On 5/27/05, Nathan Maves  [EMAIL PROTECTED]> wrote:
>
>> Since apple is taking then sweet time I just got Java 1.5.  I am
>> diving in head first but I am curious about what the plans for 
>> Generics are.
>>
>> Will I batis support them?
>> Could there be a way to specify the list type instead of Object?
>>
>> i.e.
>> return a ListStudent> back based on the result class of the query? 
>>
>> Nathan
>>
>>
>



Re: Support for generics

2005-05-27 Thread Brandon Goodin
yes, build it from the trunk.

On 5/27/05, Nathan Maves [EMAIL PROTECTED] wrote:
 Of course!
 
 Do I need to build it from the trunk?
 
 Nathan
 
 On May 27, 2005, at 8:32 PM, Clinton Begin wrote:
 
 
   I believe the new Mapper binding functionality would resolve this
 
   Nathan, are you up for trying it out?
 
   Cheers,
   Clinton
 
 
  On 5/27/05, Nathan Maves [EMAIL PROTECTED] wrote:
  gets to the DAO layer.
 
  You can cast the List but you will always get the warning for and
  unchecked assignment when the List is returned from the sqlmap.
 
  ListStudent students = (ListStudent)executeQueryForList
  (getStudents,null);
 
  Looks good but does not resolve the warnings.
 
  Nathan
 
 
  On May 27, 2005, at 2:30 PM, Larry Meadors wrote:
 
   I have done that with my DAO layer.
  
   SqlMap returns it as List, but you can cast it.
  
   Worked great. :)
  
   Larry
  
  
   On 5/27/05, Nathan Maves  [EMAIL PROTECTED] wrote:
  
   Since apple is taking then sweet time I just got Java 1.5.I am
   diving in head first but I am curious about what the plans for
   Generics are.
  
   Will I batis support them?
   Could there be a way to specify the list type instead of Object?
  
   i.e.
   return a ListStudent back based on the result class of the query?
  
   Nathan