RE: Extending IBATIs

2007-07-27 Thread Daniel Pitts
Does iBATIS use Introspector and BeanInfo?  If it does (and it should!), then 
you can create a custom BeanInfo class that defines the getter/setter methods 
for particular properties.




From: Clinton Begin [mailto:[EMAIL PROTECTED] 
Sent: Friday, July 27, 2007 8:57 AM
To: user-java@ibatis.apache.org
Subject: Re: Extending IBATIs



Can you live with simply letting it map directly to the fields?

Clinton


On 7/26/07, Jean-François Daune  [EMAIL PROTECTED] mailto:[EMAIL 
PROTECTED]  wrote: 

Hi, 

I would like to customize iBATIS by replacing use of Javabeans 
setter as default with custom setter (with a prefix). 

Is it possible? 

I do not see any extension point for this in iBATIS. 
ProbeFactory is impossible to extend. 

Cheers, 

J-F 




RE: conditionally add a table to the from clause just once if either or both of two parameters is not empty

2007-02-22 Thread Daniel Pitts
Perhaps moving that logic out of your xml file into Java land.

Assuming you have a Map as the parameter. 

boolean useSupplierForParts =
Boolean.valueOf(parameters.containsKey(supplierCompanyId) ||
parameters.containsKey(supplierRef));

Parameters.put(supplierTable, useSupplierForParts ? ,
suppliers_for_parts sp : );


Or, if you have a parameter class:

class MyParameter {
// all sorts of goodies in here...

public String supplierTable() {
   return (supplierCompanyId != null || supplierRef != null) ? ,
suppliers_for_parts sp : ;
}
}

In your map file:

SELECT whatever FROM whatever w, other_table ot, $supplierTable$




-Original Message-
From: Tim Azzopardi [mailto:[EMAIL PROTECTED] 
Sent: Thursday, February 22, 2007 5:58 AM
To: user-java@ibatis.apache.org
Subject: conditionally add a table to the from clause just once if
either or both of two parameters is not empty


ibatis2.2 java5 and 6 on winXpSp2

I'm using the code below to conditionally add a table to the from clause
of my sql if one or other or both of two parameters is not empty. (The
tricky bit is not to include add the table twice).

The following works, but I wondered if there was a simpler way that
avoids my ugly /*dummy*/ cludge.
(Without the /*dummy*/ nothing is ever generated.) 

dynamic prepend=, suppliers_for_parts sp
  isNotEmpty property=supplierCompanyId  
/*dummy*/
  /isNotEmpty
  isNotEmpty property=supplierRef
/*dummy*/
  /isNotEmpty
/dynamic
--
View this message in context:
http://www.nabble.com/conditionally-add-a-table-to-the-from-clause-just-
once-if-either-or-both-of-two-parameters-is-not-empty-tf3272865.html#a91
00250
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.


RE: who's using it?

2007-02-13 Thread Daniel Pitts
Off the record, CNET is using it for certain applications. 

-Original Message-
From: Mark Volkmann [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, February 13, 2007 9:22 AM
To: user-java@ibatis.apache.org
Subject: who's using it?

You know how when you propose using some new software library and
someone always asks Who else is using it?? Well that's where I am now
with iBATIS. I'm trying to convince a client that iBATIS is a good
solution for them. Is there a list of companies that are using iBATIS
somewhere?


RE: Map nullValue to empty collection

2007-02-09 Thread Daniel Pitts
Depending on whether you need to be able to add/remove from the
Objects list after its set:

public void setObjects(ListObject objects) {
this.objects = objects == null ? Collections.emptyList() : objects;
} 
// or
public void setObjects(ListObject objects) {
this.objects = objects == null ? new ArrayListObject() : objects;
} 


-Original Message-
From: news [mailto:[EMAIL PROTECTED] On Behalf Of Stephane Bailliez
Sent: Friday, February 09, 2007 1:49 AM
To: user-java@ibatis.apache.org
Subject: Map nullValue to empty collection


I have a setter which does no accept null values for a list, ie:

public void setObjects(ListObject objects){
if (objects == null) throw new NullPointerException(null not
permitted);
this.objects = objects;
}

I did not find yet any decent way to map a nullvalue to an empty list, I
was thinking of using a specific TypeHandlerCallback on this property on
the result map but did not go this route yet.

For now dumbest thing I could do was to remove the check and do nothing
if objects is null, other possibility include an intermediate holder
object...or ?

Any suggestions welcome.

-- stephane



Iterating through Collection.

2007-02-07 Thread Daniel Pitts
I'm passing in a Collection in the parameter map.
This allows me to pass in a Set, but ibatis doesn't seem to handle this:

com.ibatis.common.beans.ProbeException: The 'ids' property of the
java.util.HashMap class is not a List or Array.

Seems like a possible bug?


RE: cannot write to property without a setter

2007-02-06 Thread Daniel Pitts
Injection using blah.getFoo().setBar(bar); should be fine.  There isn't
any setFoo, but its not a private injection.



From: Nathan Maves [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, February 06, 2007 12:31 PM
To: user-java@ibatis.apache.org
Subject: Re: cannot write to property without a setter


I have never tried to do what you say in Spring.

In fact I have never tried it at all :)

My personal opinion is that you should never try and inject into private
properties.  Follow the bean specs and all will be well. 

Nathan


On 2/6/07, Reuben Firmin [EMAIL PROTECTED] wrote: 

Let's say I have a class structure as per below. Ibatis doesl
not seem to let me address the path foo.bah.someProperty, because there
is no setter (Foo#setBah). Specifically, I get
com.ibatis.common.beans.ProbeException : There is no WRITEABLE
property. Spring, on the other hand, is fine with this particular
setup, and in fact seems to ignore the setBah() method if it exists. Is
there a good argument for one way or the other?

public class Foo
{
private Bah bah;

public Foo()
{
bah = new Bah();
}

public Bah getBah()
{
return bah;
}
}

public class Bah
{ 
private int someProperty;

public int getSomeProperty()
...

public void setSomeProperty(int someProperty)
...
}





RE: Getting straight at the ResultSet

2007-01-04 Thread Daniel Pitts
iBATIS is used to wrap JDBC, so that you don't have to deal with the low
level details.
If you want to deal with the low level details, simply don't use iBATIS.
You are going to have an overhead if you use wrapper, but the overhead
is probably minimal.  
 
Do things the normal iBATIS way, and if you find out it is too slow, do
some profiling, don't just assume its because of a particular wrappers
overhead. You'll be disappointed very often if you assume too much..
 
 



From: Tegan Clark [mailto:[EMAIL PROTECTED] 
Sent: Thursday, January 04, 2007 12:02 PM
To: user-java@ibatis.apache.org
Subject: RE: Getting straight at the ResultSet


Damien/Larry,
 
Thanks for the reply.  I've looked at RowHandler, and unless I'm missing
something iBATIS is still controlling the iteration and passing me a Map
of the underlying data, i.e. iBATIS first incures the overhead of
adapting the ResultSet to the Map, and then I must implement some sought
of buffer to hold the returned results (unless I implement some sought
of callback out of my DAL).
 
Do my assumptions above sound correct?
 
There's no way to map the ResultSet straight back? i.e:
 
   ResultSet res = (ResultSet ) sqlClient.queryForObject();
 
Thanks again.
 
Tegan
 

Damien McCarthy [EMAIL PROTECTED] wrote:

Hi Tegan,
 
I think the RowHandler interface will provide the functionality
you need, this will allow you to iterate the objects. 
 
Take a look in p61 of the developer handbook for a nice example 
 
Damien.
 
Ps. The Handbook is at :
http://ibatis.apache.org/docs/java/pdf/iBATIS-SqlMaps-2_en.pdf
 
 
From: Tegan Clark [mailto:[EMAIL PROTECTED] 
Sent: 04 January 2007 16:21
To: user-java@ibatis.apache.org
Subject: Getting straight at the ResultSet
 
Hi group;
 
I was wondering if there is any way to receive the ResultSet
back straight from iBATIS, i.e. allow iBATIS to do the mapping on the
way in, but let me manipulate the ResultSet directly on the way out.
 
I have a framework that uses iBATIS to product no-code reports
(just the xml).  Some of those reports can stretch to 100,000's or
records though so are better suited to an iterator approach and
non-reflective mapping.
 
If it can't be done, is this something iBATIS would be
interested in having contributed?
 
All help greatly appreciated.  Thanks.
 
Tegan
 __
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 


__
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 



RE: Turning Off Ibatis SQL Mapper info..

2006-11-01 Thread Daniel Pitts



Turn logging level to WARN?


From: Urban, John 
[mailto:[EMAIL PROTECTED] Sent: Wednesday, November 01, 2006 
12:19 PMTo: user-java@ibatis.apache.orgSubject: Turning 
Off Ibatis SQL Mapper info..


Cannot figure out how to turn off 
logging. Not set it conf/log4j.xml of jboss or WEB-INF/log4j.properties. Is 
happening under jboss 3.2.6 and jdk 1.4.2 but not under jboss 3.2.6 and jdk 
1.5.0. Exact same jboss 3.2.6 configuration in both cases. Just a different 
JDK?

2006-11-01 11:49:07,584 DEBUG 
[java.sql.Connection] {conn-10} Connection
2006-11-01 11:49:07,626 DEBUG 
[java.sql.PreparedStatement] {pstm-11} PreparedStatement: 
.

And It prints out every single 
records content. This is horrible if I am returning a view with 30 columns and 
1000+ records:

2006-11-01 11:49:12,260 DEBUG 
[java.sql.ResultSet] {rset-12} Result: 
.


RE: Problem addressing list index in a parameter declaration

2006-10-30 Thread Daniel Pitts
Looks like a problem with the way ibatis handles collections. Is it
possible to iterate over the addresses, rather than manually select [0]
and [1]?
Also, might it be better design (if there is always going to be exactly
two) to have them be individual properties?  streetAddress,
apartmentAddress? I don't know your requirements, obviously, but that
might be a good work-around. 

-Original Message-
From: Reuben Firmin [mailto:[EMAIL PROTECTED] 
Sent: Thursday, October 26, 2006 3:59 PM
To: user-java@ibatis.apache.org
Subject: Problem addressing list index in a parameter declaration

I have the following code:


public class Buyer
{
...
private Address mailingAddress;
 
...


public class Address
{
private ListString addressLine;
...
public ListString getAddressLine()
{


In my insert statement, I'm addressing this as:

#mailingAddress.addressLine[0]#, #mailingAddress.addressLine[1]#,

When I start the webapp, I'm getting this exception:

[15:36:42.468] Caused by: com.ibatis.common.beans.ProbeException: There
is no READABLE property named 'addressLine[0]' in class
'com.copart.xxx.Address'
[15:36:42.468] at
com.ibatis.common.xml.NodeletParser.processNodelet(NodeletParser.java:11
4)
[15:36:42.468] at
com.ibatis.common.xml.NodeletParser.process(NodeletParser.java:75)
[15:36:42.468] at
com.ibatis.common.xml.NodeletParser.process(NodeletParser.java:93)
[15:36:42.468] at
com.ibatis.common.xml.NodeletParser.parse(NodeletParser.java:63)
[15:36:42.468] at
com.ibatis.common.xml.NodeletParser.parse(NodeletParser.java:51)

What's wrong with my code?

Thanks!
Reuben


RE: Flushing of oscache in a cluster ?

2006-09-21 Thread Daniel Pitts



We ran into a similar problem (same 
situation)
Although, we happened to have an RMI connection between 
the tool and front-end, so we used that to send "flush" 
commands.
I wouldn't recommend that though, trying to keep the 
two synchronized was a pain.

Actually, I don't know much about iBATIS's caching 
models. Maybe someone can tell us. Is there an easy/efficient way to make 
iBATIS recognize updates made by a separate process, and recache the new 
results?

My thoughts on it are that any JVM which caches through 
ibatis should be the only process to update the data. But, this seems too strict 
for real-world applications.


From: [EMAIL PROTECTED] 
[mailto:[EMAIL PROTECTED] Sent: Thursday, September 21, 
2006 8:08 AMTo: user-java@ibatis.apache.orgSubject: 
Flushing of oscache in a cluster ?


Hi 
there!

Does anyone have experience with 
this ?

As far as I have understood it, if 
you have one application split into two wep apps (1. out to web - 2. admin), 

using Ibatis DataMapper with caching 
using oscache, they both have their own cache and if you 
have

 cacheModel 
id="company-cache" type="OSCACHE"
 
flushInterval hours="1"/
 
flushOnExecute statement="updateCompany"/
 
/cacheModel

they don’t flush each other cache 
when updateCompany is run (in this case flush the web cache when a update in 
admin occur). 

So far so good (?) and here comes 
oscache clustering mechanism into the picture 
?

Have anyone been able to flush each 
other cache when you have two web apps like we have ? What did you do ? 
J

--

Since the networks guys here don’t 
like multicasting, I have been looking at JavaGroupsBroadcastingListener with a 

GossipServer or GossipRouter. Anyone 
experience with that togheter with Ibatis ?

--

My 
oscache.properties:
cache.event.listeners=com.opensymphony.oscache.plugins.clustersupport.JavaGroupsBroadcastingListener
cache.cluster.properties=UDP(ip_mcast=false;mcast_addr=224.0.0.35;mcast_port=45566;ip_ttl=32;mcast_send_buf_size=15;mcast_recv_buf_size=8)
:PING(gossip_host=10.4.0.245;gossip_port=;gossip_refresh=15000;timeout=2000;num_initial_members=3)

First of all when I run the 
GossipServer, at once it found the first client, it’s shout down. Is that 
normal, trick to make it run further ? J

Then I tried the GossipRouter and 
the consol tells me that it finds the two apps/machines it supposed to do. I’m 
running the GossipRouter on port  on machine 10.4.0.245 
which
also is one of the test clients. The 
other test machine is 10.4.1.8. 

--

Consol on the 
GossipRouter:

GossipRouter is 
starting...
GossipRouter started at Thu Sep 21 
15:57:14 CEST 2006
Listening on port  bound on 
address 
0.0.0.0/0.0.0.0 
(Does this sound good ?)
..
DEBUG 
…org.jgroups.stack.GossipRouter (Line: 313) - router accepted connection from 
Socket[addr=/10.4.1.8,port=4463,localport=]
DEBUG 
…org.jgroups.stack.GossipRouter (Line: 524) - gossip is REGISTER_REQ 
group=OSCacheBus, mbr=10.4.1.8:4296

DEBUG 
…org.jgroups.stack.GossipRouter (Line: 313) - router accepted connection from 
Socket[addr=/10.4.0.245,port=1310,localport=]
DEBUG 
…org.jgroups.stack.GossipRouter (Line: 524) - gossip is REGISTER_REQ 
group=OSCacheBus, mbr=10.4.0.245:1309

DEBUG 
…org.jgroups.stack.GossipRouter (Line: 618) - running 
sweep
DEBUG 
…org.jgroups.stack.GossipRouter (Line: 618) - running 
sweep
…


So far it’s look good in my eyes, 
then I try to test to flush the cache in one app, I was expecting the cache in 
the other app also get flushed. NOT  J

I don’t get any info in the 
GossipRouter consol, saying, got a flush command or something, should I ? The 
cache get flushed on the machine that send
the flush of course, but does anyone 
have any clues of what I can do to make the flush clustering mechanism to 
work ? should I use JMS ? 

Links to OSCACHE clusterings 
documentation:
http://www.opensymphony.com/oscache/wiki/Clustering.html

How to not using 
multicasting:
http://www.jgroups.org/newuser/node66.html

http://www.jdocs.com/jgroups/2.2.6/api/org/jgroups/stack/GossipRouter.html

You have any useful links 
?

--

So does anyone have any clues on 
what I should look at, do ? J


Thanks a lot 



Best 
regards,
Erlend 
Bjørge


RE: Postgresql serial type problem

2006-09-20 Thread Daniel Pitts



I would guess that you should omit event_id. Instead 
setting it in your java code to the return valid of the insert() 
method.


From: Okan Çetin [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, September 20, 2006 5:08 PMTo: 
user-java@ibatis.apache.orgSubject: Postgresql serial type 
problem
I have a table in postgresql and in this table there is a column 
that's type is serial. (event_id is serial )I am adding data in this 
table like this;insert 
id="insertEvent" parameterClass="Event"  
insert into PUBLIC.event ( event_id, description 
) values (  #event_id#, 
#description# ) 
/insertAlthough the data is 
correctly inserted into the table, event_id column is empty. In database side, 
event_id's type is serial, there is no problem if I add data by manually, the 
event_id is automaticly increasing. In ibatis should I do some extra config to 
do this? Thanks,Okan.-- ~otomatik oluşturuldu:http://ocetin.net/loghttp://linux.beykent.edu.tr 



RE: dynamic tables names in query problem

2006-09-19 Thread Daniel Pitts
Your iterate tag needs to specify what its iterating.
I forget off the top of my head, but I think it's the value attribute.

iterate conjunction= union all  value=values select * from
task_url_$values[]$/iterate

-Original Message-
From: Eugeny N Dzhurinsky [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, September 19, 2006 6:33 AM
To: user-java@ibatis.apache.org
Subject: Re: dynamic tables names in query problem

On Tue, Sep 19, 2006 at 04:01:38PM +0300, Eugeny N Dzhurinsky wrote:
 I'm trying to do this:
 
 statement id=prepareView parameterClass=list
 create temporary view task_url_view as
 dynamic
 iterate conjunction= union all 
 select * from task_url_$values[]$
 /iterate
 /dynamic
 /statement
 
 but this seems not work -
 weird exception is thrown: ERROR - relation task_url_$1 does not 
 exists
 
 I'm calling this statement as SqlMapClient.update(prepareView,list).

Sorry, I missed - in the SQL map there is select * from
task_url_#values[]#

with $values[]$ it doesn't want to work at all, complaining : 

ERROR - There is no READABLE property named 'values' in class
'java.util.ArrayList'

--
Eugene N Dzhurinsky


RE: underscore in java bean property

2006-09-13 Thread Daniel Pitts
Even if they don't follow the spec, here is a work around:
Create a object wrapper that DOES follow the spec, and it just delegates
to the legacy object.

If you can, however, I would refactor it to be more appropriate for
modern coding practices. 

-Original Message-
From: Nathan Maves [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, September 13, 2006 1:25 PM
To: user-java@ibatis.apache.org
Subject: Re: underscore in java bean property

What do the mutator methods look like?

If they follow the bean spec then you should be fine.

On 9/13/06, Salman Khattak [EMAIL PROTECTED] wrote:

 Strangely enough some legacy code here has underscore in property 
 names like ministry_Code. IBatis mapping does not like this. Any help 
 would be appreciated.

 This is the stack trace:


 org.springframework.jdbc.UncategorizedSQLException: SqlMapClient 
 operation; uncategorized SQLException for SQL []; SQL state [null]; 
 error code [0];
 --- The error occurred in com.xx/dao/ibatis/maps/Oing.xml.
 --- The error occurred while applying a result map.
 --- Check the Oing.minimalResultMap.
 --- The error happened while setting a property on the result object.
 --- Cause: com.ibatis.common.exception.NestedRuntimeException: Error 
 setting properties of '[EMAIL PROTECTED]'.
Cause:
 java.lang.NullPointerException
 Caused by: java.lang.NullPointerException; nested exception is
 com.ibatis.common.jdbc.exception.NestedSQLException:
 --- The error occurred in com.xx/dao/ibatis/maps/Oing.xml.
 --- The error occurred while applying a result map.
 --- Check the Oing.minimalResultMap.
 --- The error happened while setting a property on the result object.
 --- Cause: com.ibatis.common.exception.NestedRuntimeException: Error 
 setting properties of '[EMAIL PROTECTED]'.
Cause:
 java.lang.NullPointerException
 Caused by: java.lang.NullPointerException Caused by: 
 com.ibatis.common.exception.NestedRuntimeException: Error setting 
 properties of '[EMAIL PROTECTED]'.  Cause:
 java.lang.NullPointerException
 Caused by: java.lang.NullPointerException Caused by: 
 com.ibatis.common.jdbc.exception.NestedSQLException:
 --- The error occurred in com.xx/dao/ibatis/maps/Oing.xml.
 --- The error occurred while applying a result map.
 --- Check the Oing.minimalResultMap.
 --- The error happened while setting a property on the result object.
 --- Cause: com.ibatis.common.exception.NestedRuntimeException: Error 
 setting properties of '[EMAIL PROTECTED]'.
Cause:
 java.lang.NullPointerException
 Caused by: java.lang.NullPointerException Caused by: 
 com.ibatis.common.exception.NestedRuntimeException: Error setting 
 properties of '[EMAIL PROTECTED]'.  Cause:
 java.lang.NullPointerException
 Caused by: java.lang.NullPointerException
 at

com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQuery
WithCallback(GeneralStatement.java:188)
 at

com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQuery
ForList(GeneralStatement.java:123)
 at

com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForList(SqlMap
ExecutorDelegate.java:610)
 at

com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForList(SqlMap
ExecutorDelegate.java:584)
 at

com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.queryForList(SqlMapSessi
onImpl.java:101)
 at

org.springframework.orm.ibatis.SqlMapClientTemplate$3.doInSqlMapClient(S
qlMapClientTemplate.java:255)
 at

org.springframework.orm.ibatis.SqlMapClientTemplate.execute(SqlMapClient
Template.java:188)
 at

org.springframework.orm.ibatis.SqlMapClientTemplate.executeWithListResul
t(SqlMapClientTemplate.java:214)
 at

org.springframework.orm.ibatis.SqlMapClientTemplate.queryForList(SqlMapC
lientTemplate.java:253)
 at

com.xx.dao.ibatis.event.SqlMapOingDAO.getOingListByCriteria(
SqlMapOingDAO.java:43)
 at

com.xx.bo.event.EventBOImpl.getOingListByCriteria(EventBOImpl.ja
va:58)
 at

com.xx.lis.actions.ManageOingsAction.search(ManageOingsActio
n.java:177)
 at

com.xx.lis.actions.ManageOingsAction.doSecureAction(ManageOi
ngsAction.java:42)
 at

com.xx.lis.cecal.actions.SecureLoginAction.doPerform(SecureLoginActi
on.java:111)
 at
com.xx.lis.cecal.actions.BaseAction.doExecute(BaseAction.java:63)
 at

com.xx.web.struts.XxAction.doNonTransaction(XxAction.java:20
3)
 at
com.xx.web.struts.XxAction.doExecute(XxAction.java:113)
 at

com.xx.web.struts.BaseXxAction.execute(BaseXxAction.java:120
)
 at

org.apache.struts.action.RequestProcessor.processActionPerform(RequestPr
ocessor.java:431)
 at

org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:
236)
 at
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
 at

Populating existing beans...

2006-09-12 Thread Daniel Pitts
I have a 
MapInteger, MyBean byId;
Which was built by byId.put(myBean.getId(), myBean);
MyBean is the base class, there are many types of MyBean objects.

Is there a away to tell iBATIS to use the bean in byId map as the
result object? Or do I have to get the result, and copy the values over
myself?

I know it can be done with queryForObject(String, Object, Object); but I
need it for something like queryForList or queryForMap

Thanks,
Daniel.


RE: Populating existing beans...

2006-09-12 Thread Daniel Pitts



Thanks for the reply.
I'm well aware of queryForMap, but the problem isn't 
grouping the objects.

Basically, I have a bean "graph" (or tree, or whatever) 
that has been constructed before there is enough information to run the final 
query. Also, I don't know the bean class before hand (and don't want to add it 
explicitly to the resultMap or resultClass argument)

As an alternative solution to my problem, if there was a 
way to do a queryForList, but specify the result class at runtime, that would be 
extremely helpful.


From: [EMAIL PROTECTED] 
[mailto:[EMAIL PROTECTED] Sent: Tuesday, September 12, 2006 
1:24 PMTo: user-java@ibatis.apache.orgSubject: Re: 
Populating existing beans...
Daniel, there is queryForMap functionality in iBatis. It looks 
like this: SqlMapExecutor.queryForMap(statementName, parameterObject, 
key). The key will be a column in your result map which could be your 
bean.id property after the result map populates the bean. I am not sure 
what you mean by populating existing beans, but I hope this 
helps.DiranDaniel Pitts wrote: 
I have a 
MapInteger, MyBean byId;
Which was built by "byId.put(myBean.getId(), myBean);"
MyBean is the base class, there are many types of "MyBean" objects.

Is there a away to tell iBATIS to use the bean in "byId" map as the
result object? Or do I have to get the result, and copy the values over
myself?

I know it can be done with queryForObject(String, Object, Object); but I
need it for something like queryForList or queryForMap

Thanks,
Daniel.
  


RE: Populating existing beans...

2006-09-12 Thread Daniel Pitts
I could (and in fact that is what I have been doing)
But, it's a pity to do the same work that iBATIS does already when it
knows the class beforehand. 

-Original Message-
From: Chris Lamey [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, September 12, 2006 2:22 PM
To: user-java@ibatis.apache.org
Subject: RE: Populating existing beans...

On Tue, 2006-09-12 at 13:49 -0700, Daniel Pitts wrote:
 To clarify more,
 I have a bunch of beans of different classes.  There is a table for 
 each class of bean, with columns that correspond directly to bean 
 properties. This makes it easy to do things like select 
 id=getAuthors resultClass=authorSELECT * from authors/select
  
 What I'd like to do is something like
 select id=getSomething resultClass=$resultClass$
 remapResults=trueSELECT * FROM $table$/select

Could you use a map as a resultClass and based on what you pass in as
$table$, populate your bean?

Cheers,
Chris


RE: xml parser errors

2006-09-08 Thread Daniel Pitts



If you read carefully, you'll see that there is no 
WRITEABLE property named "Firstname" in class 
"com.domain.User"
This means that your com.domain.User class doesn't have a 
"setFirstname" method.
Also, the property should be start with lowercase, e.g. 
"firstname".



From: Okan Çetin [mailto:[EMAIL PROTECTED] 
Sent: Friday, September 08, 2006 11:13 AMTo: 
user-java@ibatis.apache.orgSubject: xml parser 
errors
Hi all;I'm getting some XML Parser exceptions. But the xml files 
look like correct.Where is my fault?java.lang.RuntimeException : Error 
occurred. Cause: com.ibatis.common.xml.NodeletException: Error parsing XML. 
Cause: java.lang.RuntimeException: Error parsing XPath '/sqlMapConfig/sqlMap'. 
Cause: com.ibatis.common.xml.NodeletException: Error parsing XML. Cause: 
java.lang.RuntimeException: Error parsing XPath '/sqlMap/resultMap/result'. 
Cause: com.ibatis.common.beans.ProbeException: There is no WRITEABLE property 
named 'Firstname' in class 'com.domain.User'1) 
SqlMapConfig.xml?xml 
version="1.0" encoding="UTF-8" ?!DOCTYPE 
sqlMapConfigPUBLIC 
"-//ibatis.apache.org//DTD SQL Map Config 
2.0//EN""http://ibatis.apache.org/dtd/sql-map-config-2.dtd"sqlMapConfig!-- Configure a built-in transaction 
manager.If you're using an  app server, you 
probably want to use its transaction manager  and a managed 
datasource --transactionManager type="JDBC" 
commitRequired="false"dataSource 
type="SIMPLE"property 
name="JDBC.Driver" value=" org.postgresql.Driver"/property 
name="JDBC.ConnectionURL" value="jdbc:postgresql:."/property 
name="JDBC.Username" value="postgres"/property 
name=" JDBC.Password" value="159753"//dataSource/transactionManager!-- List the SQL Map XML files. They 
can be loaded from the  classpath, as 
they are here (com.domain.data...) --sqlMap 
resource="com/data/User.xml"/ !-- List more here...sqlMap 
resource="com/mydomain/data/Order.xml"/ sqlMap 
resource="com/mydomain/data/Documents.xml"/--/sqlMapConfig2) 
User.xml?xml version="1.0" 
encoding="UTF-8" ?!DOCTYPE 
sqlMapPUBLIC 
"-//ibatis.apache.org//DTD SQL Map 
2.0//EN""http://ibatis.apache.org/dtd/sql-map-2.dtd"sqlMap namespace="User"!-- Use type aliases to avoid typing 
the full classname every time. -- typeAlias alias="User" 
type="com.domain.User"/!-- Result maps describe the mapping 
between the columns returned from a query, 
and the class properties.A result map isn't  necessary if 
the columns (or aliases) match to the properties  exactly. 
--resultMap id="UserResult" 
class="User"result 
property="Firstname" column="firstname"//resultMap!-- Select with no parameters using 
the result map for Account class. --select id="selectAllUsers" 
resultMap="UserResult" select * from user/select/sqlMapThanks;Okan.-- ~otomatik 
olu?turuldu:http://ocetin.net/loghttp://linux.beykent.edu.tr


RE: select statement problem

2006-09-08 Thread Daniel Pitts



Try executing the query manually in an sql client. Do you 
get any results?
If not, thats your problem.
Also, make sure you're using namespaces 
properly.


From: Okan Çetin [mailto:[EMAIL PROTECTED] 
Sent: Friday, September 08, 2006 1:12 PMTo: 
user-java@ibatis.apache.orgSubject: select statement 
problem
Hello;I could not getting something from db. list object 
does not contain any value. Do you have any idea ? The code and xml map 
files:  1) Code 
 
List list;   Reader reader = 
Resources.getResourceAsReader("com/data/SqlMapConfig.xml"); 
SqlMapClient sqlMapper = SqlMapClientBuilder.buildSqlMapClient 
(reader); 
reader.close();  
//usr=(User)sqlMapper.queryForObject("selectAllUsers");  
list=sqlMapper.queryForList("selectAllUsers");2) 
User.xml?xml version="1.0" 
encoding="UTF-8" ?!DOCTYPE 
sqlMap  
PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN" 
 "http://ibatis.apache.org/dtd/sql-map-2.dtd"sqlMap namespace="User" !-- Use type aliases to avoid typing the 
full classname every time. --  typeAlias alias="User" 
type="com.domain.User"/ !-- 
Result maps describe the mapping between the columns returned from a query, 
and the class properties. A result map isn't  necessary if 
the columns (or aliases) match to the properties  exactly. 
-- !-- 
resultMap id="UserResult" class="User" 
result property="firstname" column="firstname"/ /resultMap 
 -- !-- Select with no parameters using the 
result map for Account class. --  select 
id="selectAllUsers"   select firstname from 
PUBLIC.user /select/sqlMap3) 
User.javapublic class User 
{ private String 
firstname; // getter, setter 
methods.. Thanks for reply.-- ~otomatik 
olu?turuldu:http://ocetin.net/loghttp://linux.beykent.edu.tr 



RE: Update query

2006-08-24 Thread Daniel Pitts



I think his parameter class has a property named "track" 
which is a bean with a property named "id".

Anyway, I would probably debug (either set a break point, 
or just println) the value of track and track.getId() before calling this 
query.


From: puneet arya 
[mailto:[EMAIL PROTECTED] Sent: Thursday, August 24, 2006 
12:29 AMTo: user-java@ibatis.apache.orgSubject: Re: Update 
query
Hi, try to remove the . bw track and id and use 
track_id instead ..may be it workslike #track_id#Regards,Puneet 
AryaAndreas Prudzilko 
[EMAIL PROTECTED] wrote:

  
  

  
  Hello,
  
  I was wondering why my track_id is 
  set to 0 after an update statement. The #track.id# syntax worked fine for 
  insert statements, my Track object is also set properly with a valid 
  ID.
  
  Here how it looks 
  like:
  
   
  update id="update" 
  parameterClass="com.sumea.timemachine.model.SumeaProject"
   
  UPDATE project
   
  SET name = #name#,
   
  startdate = #startDate#,
   
  enddate = #endDate#,
   
  color = #color#,
   
  track_id = #track.id#
   
  WHERE project_id = #id#
   
  /update
  
  I wonder what Im doing 
  wrong.
  
  - 
  Andreas
  
  
  


Here's a new way to find what you're looking for - Yahoo! 
Answers Send FREE SMS to your friend's mobile from Yahoo! Messenger 
Version 8. Get 
it NOW


HashMaps, groupBy, error!

2006-08-24 Thread Daniel Pitts
I'm having a hard time with groupBy and hashmaps. I'm getting an
exception:
Error instantiating collection property for mapping 'blog'. Cause:
java.lang.ClassCastException: java.lang.Object

I call queryForMap(getBlogAndCategoriesForContent, parameters, blog,
category);
When my query completes, I'm expecting a MapBlog, ListCategory to be
returned.
Am I asking too much from Ibatis?

I have the following result maps/queries.

!-- stuff cut --
resultMap id=metadataNoContentId
class=cnwk.blogs.beans.Metadata
  !-- stuff cut --
result property=typeId column=typeId/
/resultMap
resultMap id=categoryDetails class=cnwk.blogs.beans.Category
extends=metadataNoContentId
result property=contentId column=category.contentId/
result property=name column=category.name/
/resultMap
resultMap id=blogAndCategoryMapping class=java.util.HashMap
groupBy=blog.contentId
result property=blog resultMap=Content.blogDetails/
result property=category
resultMap=Content.categoryDetails/
/resultMap

!-- sql select fragments --
sql id=selectBlogAndCategoryMap
SELECT * FROM $databaseName$.blogAndCategoryMap JOIN
$databaseName$.metadata ON metadata.contentId =
blogAndCategoryMap.categoryContentId JOIN
$databaseName$.category ON metadata.contentId =
category.contentId JOIN
$databaseName$.metadata AS blogMetadata ON
blogAndCategoryMap.blogContentId = blogMetadata.contentId JOIN
$databaseName$.blog ON blogMetadata.contentId = blog.contentId
/sql


sql id=blogAndCategoriesForOne
WHERE blogAndCategoryMap.contentId = #contentId#
/sql

!-- single mapping queries --
select id=getBlogAndCategoriesForContent parameterClass=map
resultMap=blogAndCategoryMapping
include refid=selectBlogAndCategoryMap/
include refid=blogAndCategoriesForOne/
/select



dynamic script's

2006-08-23 Thread Daniel Pitts
Is there a way to run an SQL script from iBATIS?
Such as:
INSERT INTO foo (#bar#, #baz#);
INSERT INTO ho (#hum#);


Also, if there is, is it possible to dynamically generate the SQL to do
so?
Eg:
INSERT INTO foo (#bar#, #baz#);
iterate property=hosINSERT INTO ho (#bar#, #hos[]#);/iterate

Thanks.





RE: dynamic script's

2006-08-23 Thread Daniel Pitts



Perhaps.
It might be nice to have some sort of scripting support 
though. Where you can at least chain operations together. Maybe something 
like:

batchTransaction id="deepInsertPost" 
parameterClass="map"
 call 
insert="insertPost"/
 iterator 
property="postData.authors"
 call 
insert="insertAuthorMap"/
 /iterator
/batchTransaction

insert id="insertAuthorMap"
 INSERT INTO authorMap (#post.id#, 
#authors[].id#)
/insert

I certainly could 
write this in java, but it seems generic enough that it might be nice to support 
it at this level.


From: Jeff Butler [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, August 23, 2006 12:52 PMTo: 
user-java@ibatis.apache.orgSubject: Re: dynamic 
script's

The answer is yes - if the driver supports it. If your driver 
supports multiple SQL statements in a single prepared statement, then you can do 
it. iBATIS doesn't to anything to support or deny this function - it's 
totally dependant on the driver support. iBATIS will only prepare one 
statement. 

In my opinion, this is a bad idea even if the driver supports it. I 
think it's better to start a transaction and make multiple calls to the 
different insert statements. More portable, and probably more 
maintainable. 

Jeff Butler

On 8/23/06, Daniel 
Pitts [EMAIL PROTECTED] wrote: 
Is 
  there a way to run an SQL "script" from iBATIS?Such as:INSERT INTO foo 
  (#bar#, #baz#); INSERT INTO ho (#hum#);Also, if there is, is 
  it possible to dynamically generate the SQL to doso?Eg:INSERT INTO 
  foo (#bar#, #baz#);iterate property="hos"INSERT INTO ho (#bar#, 
  #hos[]#);/iterate 
Thanks.


RE: CDATA inside or outside of statement tag

2006-08-23 Thread Daniel Pitts



I believe the cdata start/end will cause the dynamic tags 
to be escaped, and therefor not interpreted by iBATIS.
I would guess your second suggestion is the correct 
one.


From: Mississippi John Hurt 
[mailto:[EMAIL PROTECTED] Sent: Wednesday, August 23, 2006 1:01 
PMTo: user-java@ibatis.apache.orgSubject: CDATA inside or 
outside of statement tag
In my statement in xml, if I use dynamic tag, does the CDATA 
wrap around the whole statement, 
ieselectCDATASTARTdynamic 
/dynamicdynamic 
/dynamicCDATAEND/selector I use to use separate 
CDATA sections as in below...selectdynamic 
CDATASTART CDATAEND /dynamicdynamic CDATASTART 
 CDATAEND/dynamic/select 


RE: CDATA inside or outside of statement tag

2006-08-23 Thread Daniel Pitts
I guess I should have mentioned that too. I use lt;
I find gt; unnecessary, but I suppose some people like symmetry. 

-Original Message-
From: Nathan Maves [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, August 23, 2006 1:07 PM
To: user-java@ibatis.apache.org
Subject: Re: CDATA inside or outside of statement tag

I tend to not use them at all.  The only time I would need them is for
the standard less then or greater then symbols.

Instead I just use the html code to do this.   gt; and lt;

On 8/23/06, Daniel Pitts [EMAIL PROTECTED] wrote:


 I believe the cdata start/end will cause the dynamic tags to be 
 escaped, and therefor not interpreted by iBATIS.
 I would guess your second suggestion is the correct one.

  
  From: Mississippi John Hurt [mailto:[EMAIL PROTECTED]
 Sent: Wednesday, August 23, 2006 1:01 PM
 To: user-java@ibatis.apache.org
 Subject: CDATA inside or outside of statement tag


 In my statement in xml, if I use dynamic tag, does the CDATA wrap 
 around the whole statement, ie

 select
 CDATASTART
 dynamic  /dynamic
 dynamic /dynamic
 CDATAEND
 /select

 or I use to use separate CDATA sections as in below...
 select
 dynamic  CDATASTART  CDATAEND /dynamic
 dynamic  CDATASTART   CDATAEND/dynamic
 /select



M:N question

2006-08-23 Thread Daniel Pitts
I have something like the following:

class Foo {
  Integer fooId;
  String name;
MapInteger, ListInteger bar = new HashMapInteger,
ListInteger();
  // getters/setters bellow.
}

Table foo has (fooId, name) and table barMap has (fooId, a, b)

select id=getFoo resultMap=fullFoo
   SELECT * from foo join barMap using (fooId) WHERE fooId = #fooId#
/select

My question is... What would the resultMap have to look like to handle
bar
Or can it handle it directly?


Map from id-list

2006-08-14 Thread Daniel Pitts
I have a table that looks something like this:

external_maps
Parent  externalId  type
1   1   1
1   2   1
1   3   1
1   8   2
1   9   2
1   16  6

I want to do a query like SELECT externaId, type FROM external_maps
where Parent=%parent%

I want to get a result that is a MapInteger, Integer[] (or
MapInteger, ListInteger) where the key is type and the Integer[] (or
ListInteger)) is the list of externalId values.

Will queryForMap do this? If not, is there another (easy) way to get
this result?

Thanks,
Daniel.


RE: IBATIS error...

2006-07-28 Thread Daniel Pitts
Perhaps the JUnit test is using a different sqlMap xml file? Check and
see.  If it is, make sure that the JUnit's sqlMap xml file is
valid/correct.

-Original Message-
From: Henry Lu [mailto:[EMAIL PROTECTED] 
Sent: Friday, July 28, 2006 11:05 AM
To: user-java@ibatis.apache.org
Subject: IBATIS error...

Is there any one who has some idea about this issue?

I run a Junit testing and got the following errors:

org.springframework.beans.factory.BeanCreationException: Error creating
bean with name 'sqlMapClient' defined in file
[C:\devel\webapps\mtrain\WEB-INF\test\app_beans_test.xml]: 
Initialization of bean failed; nested exception is
com.ibatis.common.exception.NestedRuntimeException: Error occurred.  
Cause: com.ibatis.common.xml.NodeletException: Error parsing XML.  
Cause: com.ibatis.common.exception.NestedRuntimeException: Error parsing

XPath '/sqlMapConfig/sqlMap'.  Cause: 
com.ibatis.common.xml.NodeletException: Error parsing XML.  Cause: 
org.xml.sax.SAXParseException: Attribute namespace must be declared
for element type sqlMap.
Caused by: org.xml.sax.SAXParseException: Attribute namespace must be
declared for element type sqlMap.

But my web application runs with all map files and doesn't have any
errors. 

But only the JUnit testing failed.



-Henry


  



RE: SQL request with optional where

2006-06-14 Thread Daniel Pitts
Try the ibatis website? http://ibatis.apache.org/dotnetdownloads.cgi 

-Original Message-
From: xianwinwin [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, June 14, 2006 1:46 PM
To: user-java@ibatis.apache.org
Subject: Re: SQL request with optional where


thank you larry, could you kindly point to the tutorial and developer
giude. 
thanks
--
View this message in context:
http://www.nabble.com/SQL-request-with-optional-%22where%22-t1788471.htm
l#a4872438
Sent from the iBATIS - User - Java forum at Nabble.com.


RE: One query populating *multiple* lists per object returned

2006-05-11 Thread Daniel Pitts



Honestly, the solution I would choose is very 
different
Make a "Pets" table that has both dog and cat 
:-)

Or, if you must use this schema... When you query for 
people, do one query for "People with Cats", and one for "People with Dogs" and 
then merge the results.





From: Jeff Butler [mailto:[EMAIL PROTECTED] 
Sent: Thursday, May 11, 2006 2:03 PMTo: 
user-java@ibatis.apache.orgSubject: Re: One query populating 
*multiple* lists per object returned

It's not really a stupid question. The problem is that adding the Dog 
table to the join list will, in effect, create a cross join between dog and cat 
- causing lots of data to be repeated as you've seen.

There's nota great solution that I can think of. One solution 
would be to use the iBATIS group by solution and a join for one of the lists 
(cats) - as you've already accomplished. For the other list (dogs), you 
can populate it with a second query sort of like this: 

resultMap id="personMap" class="foo.bar.Person" 
groupBy="personID" result property="personID"   
  column="personID"/ 
result property="personName"   
column="personName" /  result property="cats"   
 resultMap="Persons.catsMap"/ result property="dogs" 
column="personId" 
select="getDogsByPersonId"//resultMap 

I haven't tried this for real, but I think it will work. This is 
still an N+1 query, but at least it's not 2N+1!

Another thought is that you could write your own List implementation that 
would not allow duplicates. Then it could all be done in one query because 
you would catch and throw out the duplicates in Java code. As I think 
about it, I might like this solutionbetter. There's still a bunch of 
duplicate data coming back from the DB, butthere's only on DB call. 

Jeff Butler

On 5/11/06, Rick 
Reumann [EMAIL PROTECTED] 
wrote: 
I 
  let my stupid question sit for a few days so now... Bueller,Bueller... 
  anyone, anyone ... :)On 5/9/06, Rick Reumann [EMAIL PROTECTED] wrote: I can 
  manage the n+1 stuff using groupBy when I'm populating one List per 
  object per level. Where I'm running into trouble is I want to have  
  multiple Lists populated per object. An example will hopefully help 
  clarify: Table PersonDog --- 
  personID dogID dogName Table PersonCat 
   --- personID catID 
  catName Table Person  
  personID personName 
  === Person Object 
  - List cats; List dogs; int 
  personID; String personName; (Cat class and Dog class 
  as well) ===  
  Now what I want back in one iBATIS query is a way to build a List of 
  Person objects with the Lists of Cats and Dogs populated per person 
  (assuming they have cats or dogs since either can be  
  null). I'm not sure if it's a certain orderby in the sql I 
  need to do or something I have to do with my iBATIS result maps to 
  get both lists populated correctly. I CAN get this to work 
  fine populating either Dogs or Cats (by  themself) but I can't seem to 
  create the correct query to get 'both' populated per 
  person. For example for just Cats per peson, the below works 
  (might be a typo in the below since I changed what I'm working on to 
   Cats, Dogs, Person for sake of clarity): 
  resultMap id="personMap" class="foo.bar.Person" 
  groupBy="personID"result 
  property="personID"column="personID"/ 
  result 
  property="personName" 
  column="personName" /result 
  property="cats" 
  resultMap="Persons.catsMap"/!--result 
  property="dogs" resultMap=" 
  Persons.dogsMap"/-- /resultMap 
  resultMap id="catsMap" 
  class="foo.bar.Cat" result 
  property="catID" column="catID"/  
  result property="catName" column="catName"/ 
  /resultMap resultMap id="dogsMap" 
  class="foo.bar.Dog" result 
  property="dogID" column="dogID"/  
  result property="dogName" column="dogName"/ 
  /resultMap !-- below query needs to also add dogs 
  !!! -- select id="getPersons" resultMap="personMap" 
   
  SELECT 
  p.personID, 
  p.pesonName, 
  c.catID, 
  c.catNameFROM Person 
  pLEFT JOIN Cat c ON p.personID = 
  c.personIDORDER BY 
   p.personID, 
  c.catID /select When I include the 
  result property dogs and try to join in DOGS - LEFT JOIN Dog d ON 
  p.personID = d.personID - I end up with too much duplicate data per 
  Person when iBATIS  builds my objects. I'm assuming 
  I'm missing something simple and/or being a typical idiot and doing 
  soemthing stupid? Thanks for any 
help.--Rick


Table alias in results map.

2006-03-29 Thread Daniel Pitts
I want to perform a query like:
select id=getData resultClass=map parameterClass=string
Select * FROM data AS `root:data` JOIN other AS `root:other` JOIN
something as `root:other:something` WHERE $where$
/select

The tables data, other, and something may or may not have
similarly named columns.  The aliases correspond to bean's in a map.
---CODE---
Map myQuery = new HashMap();
myQuery.put(root:data = new DataBean());
myQuery.put(root:other = new OtherBean());
myQuery.put(root:other:something = new SomethingBean());

sqlMap.queryForObject(getData, where, myQuery);
--

Unfortunately, ibatis seems to look only at the column name, not the
table name.  I would use result maps, but the query is way to dynamic.

My current kludge aliases EVERY column. This works, but is a somewhat
painful hack of introspection, and may be a performance bottleneck.

Is there any way to tell ibatis to use the table names as part of the
result map?

Much thanks in advance.
Daniel.


HashMap results and column aliased with '.' in the name.

2006-03-17 Thread Daniel Pitts
I want to get a result back as a HashMap with all the columns in the
result being keys in the map.  It makes sense for my application to have
'.'s in the column names, but ibatis is trying to map those to
properties of Object instances.
Is there any way to tell ibatis to ignore '.'s in the column name, or do
I have to find a different delineator?


RE: Re: HashMap results and column aliased with '.' in the name.

2006-03-17 Thread Daniel Pitts
Actually, it was remapped with as to the columns named with ..

I changed my implementation to use : instead, and it works. 

-Original Message-
From: news [mailto:[EMAIL PROTECTED] On Behalf Of netsql
Sent: Friday, March 17, 2006 4:41 PM
To: user-java@ibatis.apache.org
Subject: Re: HashMap results and column aliased with '.' in the name.

You can remap in sql w/ as or map the fields in XML.

.V

Daniel Pitts wrote:
 I want to get a result back as a HashMap with all the columns in the 
 result being keys in the map.  It makes sense for my application to 
 have '.'s in the column names, but ibatis is trying to map those to 
 properties of Object instances.
 Is there any way to tell ibatis to ignore '.'s in the column name, or 
 do I have to find a different delineator?