SV: Calling procedures from 2 different databases

2007-10-26 Thread erlend.bjorge
Hi there!

 

One database per SqlmapConfig - that's the rule.

 

But if your databases and the data is tightly coupled and if you don't need a 
different sqlMapConfig setting setup (don't need ping query, lazyLoadingEnabled 
setting etc)

Wouldn't it be more clean to have one sqlMapConfig file ?

 

Works super for me in a Spring app with connection to a Sybase and MS-SQL 
database, then the connectionUrl, username, password is located in a separated 
java.properties file.

It's small web app with quartz jobs, but it's the most stable application I 
have every made and easy going :-)

 

In general, you should keep the SQL for the different databases in different 
XML files - although this is not strictly required.

 

I still have have one sql.xml file for each domain model bean, so if your 
domain model bean contains data from both databases, I don't see it's good 
thing to split it in two different xml's from my point of view. Why split it ? 
Where the data is located, doesn't matter, your domain model bean does :-)

 

Anyway, feel this makes it more easy and less files to handle, from my point of 
view.

 

So, a particular instance of a DAO is tied to one and only one database.

 

Yes one DAO to one database .

 

Good luck Vinaya still :-)

 

Erlend

  

 

--

 

Fra: Jeff Butler [mailto:[EMAIL PROTECTED] 
Sendt: 24. oktober 2007 21:51
Til: user-java@ibatis.apache.org
Emne: Re: Calling procedures from 2 different databases

 

One database per SqlmapConfig - that's the rule.

 

If you have two databases, then you need two instances of the SqlMapConfig.  
IIRC you are using Spring, so...

 

1. Declare two datasources

2. Declare two SqlMapConfigs - inject a datasource accordingly

3. Inject the appropriate SqlMapConfig into the appropriate DAO.  So, a 
particular instance of a DAO is tied to one and only one database.

 

In general, you should keep the SQL for the different databases in different 
XML files - although this is not strictly required.

 

Jeff Butler

 

On 10/24/07, Vinaya Tirikkovalluru [EMAIL PROTECTED] mailto:[EMAIL 
PROTECTED]  wrote: 

Hi,

 

I am connected to 2 different databases from the application.

 

How would ibatis know which database to go when I try to access a procedure?

Can I access procedures from 2 databases within the same xml?

 

Thanks in advance

Vinaya 



SV: Connecting to 2 different Databases

2007-10-24 Thread erlend.bjorge
Hi there!

 

Your real problem working with 2 different databases, is that they are of 
different versions and as long the driver class is the same in 8i and 9i, your 
are stuck to one driver :-)

As far as I know how.

 

What you could try, is to use a 8i driver to see if the query runs agains the 
8i database, if it runs, then the fun starts :-) Then you need to find a driver 
that runs both for your 8i and 9i databases and your query :-) 9.0.2 is not the 
one :-)

 

You could try to change from java.sql.Timestamp to java.sql.Datetime if it's 
the timestamp is the problem ?

 

No you shouldn't have two config files, you could, but the problem is the same 
name on the driver class for 8i and 9i.

 

A good sql tool, is DbVisualizer, recommend the Personal one, then you can set 
up different db connetion to the same database with different jdbc driver, that 
can maybe help you to figure this out. 

 

 

Good luck !

Erlend

 

 



Fra: Vinaya Tirikkovalluru [mailto:[EMAIL PROTECTED] 
Sendt: 23. oktober 2007 21:55
Til: user-java@ibatis.apache.org
Emne: Connecting to 2 different Databases 

 

Hi,

 

I am using iBatis with Spring.

 

I need to connect to 2 databases of different versions.

I have both the data sources declared in applicationContext.xml

 

ERP is on Oracle 8i and dataware is on 9i

 

 

bean id=ERP class=org.apache.commons.dbcp.BasicDataSource

property name=driverClassName


valueoracle.jdbc.driver.OracleDriver/value

/property

property name=url

value


jdbc:oracle:thin:@abc.xyz.com:4545:dev

/value

/property

property name=username

valueuser/value

/property

property name=password

valuepassword/value

/property

/bean

bean id=dataware

class=org.apache.commons.dbcp.BasicDataSource

property name=driverClassName


valueoracle.jdbc.driver.OracleDriver/value

/property

property name=url

value


jdbc:oracle:thin:@ddd.xyz.com::DWD

/value

/property

property name=username

valueuser/value

/property

property name=password

valuepassword/value

/property

/bean

 

 

I am using jdbc_9.0.2.jar. 

I am getting the following error while executing the query for a table in 8i 
database..

 

 

Executing Statement:   select  PO_NBR, SCHEDULE_DATE, PROMISE_DATE, 
ORDER_QTY, SHIPPED_QTY,   CANCELLED_QUANTITY, ONHAND_QTY, HOLD_NAME 
from XTRADE_OWNER.OPEN_SO_LINES_VWwhere   (   
PROMISE_DATE =   ?)   

[DEBUG,PreparedStatement,http-8080-Processor25] {pstm-100180} Parameters: 
[2005-02-06 00:00:00.0]

[DEBUG,PreparedStatement,http-8080-Processor25] {pstm-100180} Types: 
[java.sql.Timestamp]

[DEBUG,HttpSessionContextIntegrationFilter,http-8080-Processor25] 
SecurityContextHolder set to new context, as request processing completed

[ERROR,[Faces Servlet],http-8080-Processor25] Servlet.service() for servlet 
Faces Servlet threw exception

java.sql.SQLException: ORA-01024: invalid datatype in OCI call

 

 

The same type of query works fine in 9i database. I hace a single sqlConfig.xml

Do I need to have 2 different sqlConfig files each for each database? How do I 
specify the drivers?

 

Thanks

Vinaya



This electronic message is intended only for the use of the individual(s) or 
entity(ies) named above and may contain information which is privileged and/or 
confidential. If you are not the intended recipient, be aware that any 
disclosure, copying, distribution, dissemination or use of the contents of this 
message is prohibited. If you received this message in error, please notify the 
sender immediately. 



SV: Updated IDEA plug-in for iBATIS

2007-10-04 Thread erlend.bjorge
Hi there!

This plugin looks great, but are you also thinking about a feature like this:

Generate CRUD SQL . with default class or alias as input param ?

???

This feature should also have the possibilities to change the default query 
names for each CRUD operation from e.g:

Default:   Custom:
select$Class name$ ... to  fetch$Class name$  ... 
delete$Class name$ ... to  remove$Class name$ ...

Then you could do this once, instead of 4 times in each xml for each bean.

Keep up the good work!


Best regards,
Erlend Bjørge


SV: Updated IDEA plug-in for iBATIS

2007-10-04 Thread erlend.bjorge
Hi again!

To quick respons last time:

We now have intentions for automatically creating result maps and all
CRUD operations (insert, select, update, and delete).

Yes you are planning automatically creating all CRUD operations :-)

That's realy good! ... but remember the option to override 
the default query names!

Erlend


SV: Pagination

2007-07-02 Thread erlend.bjorge
Hi there!

In your dao class you can call the sqlMap for example like this:

result = sqlMap.queryForList(searchCompanies, searchBean, ((pageNumber-1) * 
pageSize), pageSize);

Use of variables named like this, makes it more easy to read if you ask me :-)


Take care,
Erlend

-Opprinnelig melding-
Fra: Hemant.Kamatgi [mailto:[EMAIL PROTECTED] 
Sendt: 2. juli 2007 18:07
Til: user-java@ibatis.apache.org
Emne: RE: Pagination

Correct, In our project we've used the below api to achieve pagination 
successfully.

public List queryForList(String id, Object parameterObject, int skip, int max)

Rgds
HK

-Original Message-
From: Clinton Begin [mailto:[EMAIL PROTECTED] 
Sent: Monday, July 02, 2007 10:59 AM
To: user-java@ibatis.apache.org; [EMAIL PROTECTED]
Subject: Re: Pagination

Right.  Don't use the paginator stuff...but feel free to still use the
query limits:

queryForList(statement, param, offset, maxrows)

clinton

On 7/1/07, Larry Meadors [EMAIL PROTECTED] wrote:
 The best example is one that doesn't exist: don't use it. :)

 It's not going to be in iBATIS 3 because it's not really part of the
 core of what iBATIS does - mapping data.

 Most all modern databases provide similar functionality that will
 perform better, and use fewer resources.

 Larry


 On 7/1/07, André Rodrigues Pena [EMAIL PROTECTED] wrote:
  Hi all,
  I'm new to iBatis. I'd like to see a complete example of how to use
  pagination in my queries. I searched google but I didn't find an example
  including both query and java example of usage.
 
  Thanks in advance
 
  --
  André Rodrigues Pena



SV: Pagination

2007-07-02 Thread erlend.bjorge
To make it more clear... then your first page starts on page 1
(pageNumber = 1) .. so you don't have to transform the value you 
send in for page 1, to 0 :-)

Clear as ink :-)

-Opprinnelig melding-
Fra: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
Sendt: 2. juli 2007 18:13
Til: user-java@ibatis.apache.org
Emne: SV: Pagination

Hi there!

In your dao class you can call the sqlMap for example like this:

result = sqlMap.queryForList(searchCompanies, searchBean, ((pageNumber-1) * 
pageSize), pageSize);

Use of variables named like this, makes it more easy to read if you ask me :-)


Take care,
Erlend

-Opprinnelig melding-
Fra: Hemant.Kamatgi [mailto:[EMAIL PROTECTED] 
Sendt: 2. juli 2007 18:07
Til: user-java@ibatis.apache.org
Emne: RE: Pagination

Correct, In our project we've used the below api to achieve pagination 
successfully.

public List queryForList(String id, Object parameterObject, int skip, int max)

Rgds
HK

-Original Message-
From: Clinton Begin [mailto:[EMAIL PROTECTED] 
Sent: Monday, July 02, 2007 10:59 AM
To: user-java@ibatis.apache.org; [EMAIL PROTECTED]
Subject: Re: Pagination

Right.  Don't use the paginator stuff...but feel free to still use the
query limits:

queryForList(statement, param, offset, maxrows)

clinton

On 7/1/07, Larry Meadors [EMAIL PROTECTED] wrote:
 The best example is one that doesn't exist: don't use it. :)

 It's not going to be in iBATIS 3 because it's not really part of the
 core of what iBATIS does - mapping data.

 Most all modern databases provide similar functionality that will
 perform better, and use fewer resources.

 Larry


 On 7/1/07, André Rodrigues Pena [EMAIL PROTECTED] wrote:
  Hi all,
  I'm new to iBatis. I'd like to see a complete example of how to use
  pagination in my queries. I searched google but I didn't find an example
  including both query and java example of usage.
 
  Thanks in advance
 
  --
  André Rodrigues Pena



SV: Lack of BeanInfo support

2006-10-17 Thread erlend.bjorge








Hi !



Don't fall for
Sun Standards. I did, and iBATIS is worse for it. 

Interesting, can you tell us a little more about that ? whats
worse ? J



Thanks,

Erlend 








SV: Automatic rollback with Spring for junit tests ? SOLUTION :-)

2006-10-04 Thread erlend.bjorge
Hi!

Just use AbstractTransactionalDatabaseTestCase or whatever it's
called. 

It's not called that, will try to look find it, but do you know the name ?

Sounds more easy to use if it do what I think it does :-)

Thanks!
Erlend


Automatic rollback with Spring for junit tests ?

2006-10-03 Thread erlend.bjorge








Hi there!



Im trying to set
up some junit tests and want to take automatically a rollback for each test, in
a Spring context.



Any clues how to set this
property transactionManager (see below for the error) correctly in Spring ? 



I have tried to use the AbstractTransactionalSpringContextTests
feature from Spring without any luck so far.

With the AbstractSpringContextTests
it works fine.





Thanks,

Erlend



--



I get this error:



..

..

2006-10-03 15:53:01,734
[INFO  ] [main  ]
org.springframework.context.support.ClassPathXmlApplicationContext - Unable to
locate MessageSource with name 'messageSource': using default
[EMAIL PROTECTED]

2006-10-03 15:53:01,734
[INFO  ] [main  ]
org.springframework.context.support.ClassPathXmlApplicationContext - Unable to
locate ApplicationEventMulticaster with name 'applicationEventMulticaster':
using default [EMAIL PROTECTED]

2006-10-03 15:53:01,734
[INFO  ] [main  ]
org.springframework.beans.factory.support.DefaultListableBeanFactory -
Pre-instantiating singletons in factory
[org.springframework.beans.factory.support.DefaultListableBeanFactory defining
beans [configurator,sqlMapClient,sqlMapClientTemplate,contactDao,dataSource];
root of BeanFactory hierarchy]



org.springframework.beans.factory.UnsatisfiedDependencyException:
Error creating bean with name 'no.aftenposten.contactinfo.dao.ibatis.ContactDaoTest':
Unsatisfied dependency expressed through bean property 'transactionManager':
set this property value or disable dependency checking for this bean

    at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.checkDependencies(AbstractAutowireCapableBeanFactory.java:995)

    at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:856)

    at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireBeanProperties(AbstractAutowireCapableBeanFactory.java:227)

    at
org.springframework.test.AbstractDependencyInjectionSpringContextTests.setUp(AbstractDependencyInjectionSpringContextTests.java:187)

    at
com.intellij.rt.execution.junit2.JUnitStarter.main(JUnitStarter.java:32)

    at
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

    at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

    at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

    at
com.intellij.rt.execution.application.AppMain.main(AppMain.java:90)

--



My spring-dao.xml 



 !-- Section 4
--

    bean
id=sqlMapClient
class=org.springframework.orm.ibatis.SqlMapClientFactoryBean

    property
name=configLocation

   
valueclasspath:sql/SqlMap-config.xml/value

    /property

    property
name=useTransactionAwareDataSource

   
valuefalse/value

    /property

    property
name=dataSource

    ref
bean=dataSource/

    /property

    /bean



    !-- Section 5
--

    bean
id=sqlMapClientTemplate class=org.springframework.orm.ibatis.SqlMapClientTemplate

    property
name=sqlMapClient

    ref
bean=sqlMapClient/

    /property

    /bean



    !-- Section 6
--

    bean
id=contactDao
class=no.aftenposten.contactinfo.dao.ibatis.ContactDaoImpl

    property
name=sqlMapClient

    ref
bean=sqlMapClient/

    /property

    /bean



    !--
javax.sql.DataSource supplied by Jakarta Commons Connection Pooling --

    bean
id=dataSource lazy-init=true class=org.apache.commons.dbcp.BasicDataSource
destroy-method=close

    property
name=driverClassName

   
value${application.db.driver}/value

    /property

    property
name=url

   
value${application.db.url}/value

    /property

    property
name=username

   
value${application.db.username}/value

    /property

    property
name=password

   
value${application.db.password}/value

    /property

    /bean








SV: Automatic rollback with Spring for junit tests ? SOLUTION :-)

2006-10-03 Thread erlend.bjorge








Hi there!



I was struggling with this
problem, then I finally realized the problem, ME J



I have been using Hibernate
with Spring (someone else has setup the transactionManager stuff), and when 
I realized what I was actually missing then wola J This line here in the spring-dao.xml file of course J



    bean
id=transactionManager
class=org.springframework.jdbc.datasource.DataSourceTransactionManager

    property
name=dataSource

    ref
bean=dataSource/

    /property

    /bean



But are other better ways
to do it ?



--



Anyway nice Ibatis/Spring
links:



http://www.learntechnology.net/struts-spring-ibatis.do  
(The example I was using, but they didnt have the transactionManager
setup)



Reading this I figured it
all out J



http://www.springframework.org/docs/reference/orm.html#orm-ibatis





Take care,

Erlend










SV: Flushing of oscache in a cluster ?

2006-09-22 Thread erlend.bjorge
Hi Brian!

Are you sure you need to cache?  

Pretty sure :-) Have worked pretty well so fare.

What metrics do you have to warrant the additional complexity?  

Until now we haven't seen it with extra complexity. When I started to use it, I 
liked it a lot :-) The shit hit the fan :-) when we tried to introduced load 
balancing, easily explained:

2 servers = 2 web and 2 admin = 4 applications :-)

I think too many j2ee books convince developers to avoid frequent 
communications with the database without calculating the performance numbers 
in their own applications.  

The question is also, where to put the time to optimize your application,
in the java code or the database. Of course the queries etc need to be
good enough, but when you starts to talk about materialized views it's 
starts to get a little fishy. How much logic should you put in the 
application or database. Tricky question, I like to do it more in the 
application if I can. 

But when that's said we have similar solutions for the most heavy stuff. A 
Oracle guy made a package that made some kind of index table, he called it. 
Save us for many minutes in some quartz jobs we have running, also. I have 
removed N+1 selects etc. So we have focus on the query performance it's not 
that, of course we can be better too.

--

Our application is something like yellow page catalogue +++, search text 
queries (we use Oracle Text), batch jobs counting up companies in business 
categories etc.

 http://www.aguiden.no  (also a web cache over here...)

Notice it's slightly quicker when searching the same word the second time = 
cached :-) The database server also server other applications and sometimes 
breath heavy.

view and the database level with query rewrites.  Each database vendor offers 
many features.  That's why I like iBatis, it lets me work with my oracle 
database productively.

Yes... I understand you, but as we want it with load balancing = 2 admin 
applications too, should also flush each other cache, I should realy want
this oscache cluster mechanism to work.

On paper it seems pretty easy, do a little stuff in the property file, setting 
up this GossipRouter, but where have a missed the point since it's not working 
??? :-) Or should I do it a complete other way ? Find it strange that it 
seems no one seems to been trying this before ? h

Anyway thanks for you thoughts still!


Have nice weekend!
Erlend


SV: Abator wishlist

2006-06-23 Thread erlend.bjorge








Hi there!





Gareth wrote:
Most of the hand
written domain objects I have are completely flat POJOs - there is no separate
class for primary key - most of the time, there are no primary keys on the database - so I'd like
all of the Abator generated objects to be the same. Can we turn off generation
of primary key classes for those tables
where primary keys are present and just use flat objects?



I have been using Ibatis for
2 years (and Hibernate for 1 year) now and Im not sure why you want
to have separate primary key classes for your model beans ? 

Not sure why that should
be good for ? News for me, can anyone tell me why ? J 



Btw, not heard about
Abator before, that sound interesting J



Thanks,

Erlend Bjørge















SV: Abator wishlist

2006-06-23 Thread erlend.bjorge








Hi there Jeff!





The primary key class is seperated so that the method signatures for
selectByPrimaryKey and deleteByPrimaryKey can only require the primary key, and
not the class that represents the entire row. 



I see, was thinking about
that, but I havent got that problem, I always have like this
fetchObjectById(Integer id), deleteObjectById(Integer key1, Integer key2). Shouldnt
that be a better way ? 

If you need an update..
you have to have the data too, so what do you do then ? update(pk, bean) ?



I did it that way because I have strong dislike ofusing half
empty objects. 



Yes I see that problem
(we have it J), but thats not related to select, delete
methods where you only need the PK as an parameter, as we do it.



For example,if the deleteByPrimaryKey method took the entire
row as a parameter, everyone would have to remember what fields are in the
primary key and only set those fields - yuck. 



Yes, Im agree, but
why create and hole primaryKey object, instead of
just sending in the PK itself as an parameter ? J But I guess
this is related to the nature of how Abator works behind the scene ?





Thanks for the answers
anyway!



Cheers,

Erlend Bjørge










SV: Abator wishlist

2006-06-23 Thread erlend.bjorge








Hi therae Christopher!



PrimaryKey
class in the first place the impact would have been greatly reduced and almost
negligible. I learned my lesson and now always create a PrimaryKey class for
every Domain object. 

And as
you stated below, it provides a much cleaner interface to the
selectByPrimaryKey and deleteByPrimaryKey methods.



Yes, see that point..
.havent got that problem yet need to change the type of the pk J 

Need to think about that
issue here.



Thanks for info!



Cheers,

Erlend Bjørge








SV: pager in ibatis

2006-04-26 Thread erlend.bjorge
Hi there!

Yusuf wrote
I think it's better off making the paging logic yourself in the
application, and then querying only the records you want to show, for
example in oracle you can use the rownum to fetch the data like

select * from 
(select rownum row, a.* from tabel1 as a)
where row between 21 and 30
/Yusuf wrote

Why not use the ibatis the queryForList with pageNumber and pageSize 
parameters like this:

sqlMap.queryForList(searchCompanies, searchText, ((pageNumber-1) * pageSize), 
pageSize);

??

Then you only keep track of the pageNumber you are at and don't need to make 
your query database specific... and you don't worry about the caching, it cache 
the page you are at and only that as far as I have understood it.

You also need the countSearchCompanies, with an exactly the same query but with 
count in it . to find out how many pages it totally for that search. So you 
can specifiy page 1, 2, 3, 4 in e.g. your webpage.

We use this strategy with success here:

http://www.aguiden.no   (search for sykkel (bike),gives you two pages)

Since queryForPaginatedList don't have a count (??), I don't think it load the 
totally result set, only the page you are at, and have lazy loading of the next 
page... smooth.

So far as I have understood it ???


Take care,
Erlend

---


-Opprinnelig melding-
Fra: Yusuf [mailto:[EMAIL PROTECTED] 
Sendt: 13. april 2006 02:44
Til: user-java@ibatis.apache.org
Emne: RE: pager in ibatis

I think it's better off making the paging logic yourself in the
application, and then querying only the records you want to show, for
example in oracle you can use the rownum to fetch the data like

select * from 
(select rownum row, a.* from tabel1 as a)
where row between 21 and 30

because using the queryForPaginatedList (without caching) will always
fetch the entire result and then showing only the selected records, and
if the record count is high (like thousands..) then the performance will
be bad.

cmiiw,
Yusuf.

-Original Message-
From: John Chien [mailto:[EMAIL PROTECTED]
Sent: Wednesday, April 12, 2006 11:27 PM
To: user-java@ibatis.apache.org
Subject: Re: pager in ibatis


L:arry:

Thank you for the information.
The queryForPaginatedList() will return a list, then I can check for the

existence of successive records by calling the isNextPageAvailable().
and go to that page by calling  gotoPage();

However, I can not keep this list in my server due to concurrecy reason.
Does that mean that I have to call the same method every time and  give 
it the page number for it to return me the records ?

I am doing the web development.
How can I make use of this returned list in JSP with Struct development
?

Should I keep the list in the session or request scope ?

Thanks,

John Chien

Larry Meadors wrote:

queryForPaginatedList()

Larry


On 4/12/06, John Chien [EMAIL PROTECTED] wrote:
  

Dear sir:

I have a feature that requires me to return query result of a
selection
statment in certain amount of successive records every time.
This is just like a page.

For example:

SELECT  id, name
FROM employee;

The selection result of this statement is a list.
However, I want to only get 30 records every time.
For the first call, I want to get the first 30 (1 - 30) records, for
thext call, I would like to get the next 30 (31 - 60) records.

How can I do this in Ibatis ?

Thanks,

John Chien








Connection hangs with SQL query string 1983 of length, can this be a SQLMap bug ?

2005-09-07 Thread erlend.bjorge
Hi there!

When digging for the error in my previous message:

Possible to set timeout on the connection ?

I came over a very strange bug somewhere from SQLMap, the Oracle 
driver classes12.jar and to the database Oracle 9.2.

I do a plain SQL without binding variables (I do $complexWhere$ - 
myBean.geComplexWhere) in the 
xml file) the query looks like this from the debug info:

DEBUG 2005-09-07 11:55:50,003 
com.ibatis.common.jdbc.logging.PreparedStatementLogProxy (Line: 48) - 
{pstm-17}
PreparedStatement:  select C.COMPANYID, C.DMID, .. where ... 
and (( C.ORGANIZATIONNO like '%Galleri 
Henrik%' 
or  lower(C.BUSINESSNAME) like 
lower('%Galleri Henrik%') 
or  lower(C.MARKETNAME) like 
lower('%Galleri Henrik%') ..) ) ) 
order by  .

DEBUG 2005-09-07 11:55:50,023 
com.ibatis.common.jdbc.logging.PreparedStatementLogProxy (Line: 49) - 
{pstm-17}Parameters: []
DEBUG 2005-09-07 11:55:50,033 
com.ibatis.common.jdbc.logging.PreparedStatementLogProxy (Line: 50) - 
{pstm-17} Types: []

(mine lineshifts in the query, and mine replacments of sql with .)

---

The query string is of 1983 length (if you count the spaces before the select 
statment), 
or 1973 without the spaces, no tail whitespaces counted. When I search e.g. for 
'Galleri Henrik',
the query string get exactly total 1983 of length. But lets say it's 1983 then.

SO WHEN the query string is of exactly 1983 of length the SQLMap connection 
hangs and I get some kind 
of lock in the database (CURSOR BIND). Believe it or not !!! I still can't 
believe it :-)

One Oracle guru told me that the case could be that Oracle are not able to 
return the result 
back again after doing this query and goes into somekind of wait modus. Waiting 
for something 
for the connection ?? I don't have a clue.

It's nothing wrong with the data or the SQL. I can copypaste this query string 
into a SQL 
tool, using the same Oracle JDBC driver as SQLMap does (I use DbVisualizer), 
and run the 
query with or without the whitespaces in front, and the query runs just fine 
under 1 second.

This make me think, can this has something with SQLMap to do ? Do SQLMap 
somekind of string
manipulating that could result in some kind of modus when the query string is 
of 1983 in length ?
Oracle can handle more then that of course and should be discovered for a long 
time agao if that 
was the case ? Same with the driver, but what about SQLMap ??? A bug ? 

It's a actually unbelievably this case, when the query string is less or larger 
than 1983, no problem 
at all, makes it even more strange. As my previous e-mail, when size is 1982 or 
1984 no problem,
And it's not related to Galleri Henrik .. I can typ in '1234567 123456' - same 
error, it's the length !!

--

Have you heard of this before ? :-) Any wild ideas ?? Something I should test ?

--

The quick solution is to remove many whitespaces in the sql string = become 
less that 1983 
of length with normal searches. Not that quick is to make binding variables. 
Tested both, works just fine.

We use the SQLMap version available in january 2005.

Clues ?


Cheers,
Erlend 


SV: Connection hangs with SQL query string 1983 of length, can this be a SQLMap bug ?

2005-09-07 Thread erlend.bjorge
Hi there!

Wow, that is a wacky one..it seems most likely that it is a driver issue (i 
can promise that there is no 
if(sql.length() == 1983) blowChunks(); code in SQL Maps.

:-)

Can you try it with the latest Oracle drivers? 
From all reports, the 10g drivers resolved a ton of bugs that were popping up.

10g drivers ? Not sure what you mean ? We are running 9.2, found det 
ojdbc14.jar driver and tested 
it and general speaking the driver worked with our code at least.

BUT when I tried to reproduce the error from yesterday with old driver, I was 
not able to do it !! :-(

What a luck. This error has been present for 1 week now. But it was yesterday I 
found out the 1983 case.
Since yesterday, haven't done anything that should have caused any bug fix's 
with this problem, 
even brought back some CVS version of part of the code involved, no luck either 
to reproduce it now. 

The only difference I can think of is the load of the system at the moment from 
yesterday when I 
found the bug. Will try tomorrow again with the old driver to see if I can 
reproduce it, and 
then only switch to the new driver if it pop up again.

It might not hurt to update to a more recent iBATIS build, too.

Thougth of that too, but at the moment too much testing of rest of the 
application,
to be on the safe side before an upgrade :-) But we should do it soone yes.

--

Anyway thanks for the driver tip, think we 
has been using the classes12.jar by an old habit :-)


Cheers,
Erlend


How to force Integer instead BigDecimal with queryForMap for the value part ?

2005-08-30 Thread erlend.bjorge
Title: Melding



Hi 
there!

I have a queryForMap 
like this:

HashMap codes 
= (HashMap) sqlMap.queryForMap("retrieveAdminUserAccessCodes","testUser", "CODE", "VALUE"));

And the query like 
this:

 select 
id="retrieveAdminUserAccessCodes" resultClass="java.util.HashMap" 
parameterClass="String" 
selectCODE, 
VALUE from 
ADMINUSERACCESS
 where 
ADMINUSERNAME = #value# /select


VALUE is 
NUMBER(5) in a Oracle 9.2 database, when I get it back, codes, 

the VALUE part 
is of type BigDecimal,is it possible to get it as an 
Integer instead ? hmm

Or is it other 
ways to do this in a better way ?


Thanks!
Erlend


SV: [REPOST] sqlMap + multiple deletes: getting the total number of rows deleted

2005-08-24 Thread erlend.bjorge
Hi there!

Have you tried with FK and cascade delete ?

Which means one delete statement, but behind the scene, deletes in several 
tables,
the number of deleted rows should then be correct ?

Erlend

---

[Looks like my first post got lost when the list went down :-/]

Hi,

I'm a newbie to iBatis and as part of some unit-testing I need to confirm 
that the correct number of rows are deleted when removing some records.

If do

delete id=deleteXY
delete from X where id=#value#;
delete from Y where id=#value#;
/delete

I get the number of rows deleted from Y only.

If I split the delete into two separate entries:

delete id=deleteX
delete from X where id=#value#;
/delete

delete id=deleteY
delete from Y where id=#value#;
/delete

and call them both, I get the expected number of rows deleted when I add them.

Is there a way to have only one call to delete/ and get the total 
number of rows deleted ?

TIA.

-- 
Graeme -


SV: Capitlizing first letter in words

2005-07-11 Thread erlend.bjorge
Title: Melding



Hi 
there!

One 
easy trick is to use the database function, in Oracle: 
initcap

select 
initcap(name), initcap(contactperson) ...
from 
company

--

But 
still you have the problem with words that you don't want to initcap 
..
words 
like:

and, 
or ...

--

Let me 
know if you figure out a easy way handle those special word you don't want to 
initcap !! :-)

Think 
you have to have some kind of list of words that should be in lower, maybe there 
are some kind 
of 
utility out there for that ?


Take 
care,
Erlend

-

  
  -Opprinnelig melding-Fra: Folashade Adeyosoye 
  [mailto:[EMAIL PROTECTED] Sendt: 10. juli 2005 
  14:27Til: ibatis-user-java@incubator.apache.orgEmne: 
  Capitlizing first letter in words
  
  Is there any such feature in 
  iBatis, where the first letters returned are capitalized, if all the data in 
  DB are all lower cases?
  
  I know another alternative is to 
  modify my setters to capitalize the first letter, I think it’s a pain in the 
  rear to do that for all the attributes.
  
  Shardayyy
  


SV: SAXParseException, parsing the sqlMap-config.xml file!

2005-07-08 Thread erlend.bjorge
Hi there!

Apparently you have an element type that is not in proper order with the DTD.

You are right, after downloaded the JEdit (thanks for the tip) with the xml 
parser plugin, tested with the sqlMap-config file from the sqlMap pdf file ... 
I found out it was the order. I had it like this: 

transactionManager
typeAlias

It should have been:

typeAlias
transactionManager

Yes  !

---

This problem started without my knowlegde for 1 month ago when I moved the 
typeAlias from
the sql xml files to the sqlMap config file ... But didn't get any error 
messages then,
so it seems to be cached somewhere in IntelliJ for me with out my knowlegde. 
But did a lot
of refactoring of the alias... Strange that it's still cached somewhere.

So that's why I though it was something else, but as usual you should trust the 
error messages :-)
In away I did understand the error message, but couldn't beleive it :-)

---

Check your sql map config and make sure your elements are properly ordered.

Is there an reason why typeAlias should be first ? I found it more correct it 
should be after... But maybe because you can use typeAlias to more then just
classes ??


Take care and thanks alot of 
clues to find the error!


Cheers,
Erlend 


SAXParseException, parsing the sqlMap-config.xml file!

2005-07-07 Thread erlend.bjorge
Title: Melding



Hi 
there!

In my IntelliJ, in 
our Resin web applications it all works just fine with SQLMap, but when I 
tries to 
run a scheduler job 
(Quartz) from command prompt using SQLMap from a .bat file (I 
run the job
from IntelliJ it 
works fine)it seems thatsuddenly the parsingof theconfig file is not working 
anymore.

I have also tried to 
copy the java command run by IntelliJ, into the bat file I'm starting so I get 
as close as 
I can get the 
same 
"environment" as the one in IntelliJ, still the same 
problem.

Does anyone have any 
clues about what's wrong ? Some kind of conflict with the dtd ??? but why now 
?
Can it be some kind 
of conflict of .jar files ?Need to change the sequence ? Pretty lost here 
now.

Thanks for any 
clues!

Erlend 
Bjørge



Here is the 
exception I get, check the red line where the exception happens in my code, look 
further down.

---

java.lang.ExceptionInInitializerError 
at 
no.aftenposten.multimedia.aguiden.bus.facade.FacadeFactory.getFacadeAdmin(FacadeFactory.java:19) 
at 
no.aftenposten.multimedia.aguiden.bus.common.batch.AGuidenDBUpdater.init(AGuidenDBUpdater.java:42) 
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native 
Method) at 
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) 
at 
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) 
at 
java.lang.reflect.Constructor.newInstance(Constructor.java:274) 
at 
java.lang.Class.newInstance0(Class.java:308) 
at 
java.lang.Class.newInstance(Class.java:261) 
at 
org.quartz.core.JobRunShell.initialize(JobRunShell.java:135) 
at 
org.quartz.core.QuartzSchedulerThread.run(QuartzSchedulerThread.java:335)Caused 
by: com.ibatis.common.exception.NestedRuntimeException: Error occurred. 
Cause: com.ibatis.common.xml.NodeletException: Error parsing XML. Cause: 
org.xml.sax.SAXParseException: The content of element type "sqlMapConfig" must 
match 
"(properties?,settings?,typeAlias*,typeHandler*,transactionManager?,sqlMap+)+".Caused 
by: org.xml.sax.SAXParseException: The content of element type "sqlMapConfig" 
must match 
"(properties?,settings?,typeAlias*,typeHandler*,transactionManager?,sqlMap+)+".Caused 
by: com.ibatis.common.xml.NodeletException: Error parsing XML. Cause: 
org.xml.sax.SAXParseException: The content of element type "sqlMapConfig" must 
match 
"(properties?,settings?,typeAlias*,typeHandler*,transactionManager?,sqlMap+)+".Caused 
by: org.xml.sax.SAXParseException: The content of element type "sqlMapConfig" 
must match 
"(properties?,settings?,typeAlias*,typeHandler*,transactionManager?,sqlMap+)+". 
at 
com.ibatis.sqlmap.engine.builder.xml.SqlMapConfigParser.parse(SqlMapConfigParser.java:81) 
at 
com.ibatis.sqlmap.client.SqlMapClientBuilder.buildSqlMapClient(SqlMapClientBuilder.java:62) 
at 
no.aftenposten.multimedia.aguiden.bus.facade.AgFacade.getSqlMapClient(AgFacade.java:39) 
at 
no.aftenposten.multimedia.aguiden.bus.facade.AgFacade.clinit(AgFacade.java:20) 
... 10 moreCaused by: com.ibatis.common.xml.NodeletException: Error parsing 
XML. Cause: org.xml.sax.SAXParseException: The content of element type 
"sqlMapConfig" must match 
"(properties?,settings?,typeAlias*,typeHandler*,transactionManager?,sqlMap+)+".Caused 
by: org.xml.sax.SAXParseException: The content of element type "sqlMapConfig" 
must match 
"(properties?,settings?,typeAlias*,typeHandler*,transactionManager?,sqlMap+)+". 
at 
com.ibatis.common.xml.NodeletParser.parse(NodeletParser.java:53) 
at 
com.ibatis.sqlmap.engine.builder.xml.SqlMapConfigParser.parse(SqlMapConfigParser.java:78) 
... 13 moreCaused by: org.xml.sax.SAXParseException: The content of element 
type "sqlMapConfig" must match 
"(properties?,settings?,typeAlias*,typeHandler*,transactionManager?,sqlMap+)+". 
at 
org.apache.xerces.framework.XMLParser.reportError(XMLParser.java:1213) 
at 
org.apache.xerces.validators.common.XMLValidator.reportRecoverableXMLError(XMLValidator.java:1851) 
at 
org.apache.xerces.validators.common.XMLValidator.callEndElement(XMLValidator.java:1495) 
at 
org.apache.xerces.framework.XMLDocumentScanner$ContentDispatcher.dispatch(XMLDocumentScanner.java:1149) 
at 
org.apache.xerces.framework.XMLDocumentScanner.parseSome(XMLDocumentScanner.java:381) 
at 
org.apache.xerces.framework.XMLParser.parse(XMLParser.java:1098) 
at 
org.apache.xerces.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:195) 
at 
com.ibatis.common.xml.NodeletParser.createDocument(NodeletParser.java:150) 
at 
com.ibatis.common.xml.NodeletParser.parse(NodeletParser.java:50) 
... 14 more



Here is my 
config file with the "correct" header:

-

?xml 
version="1.0" encoding="UTF-8" ?!DOCTYPE sqlMapConfig PUBLIC 
"-//iBATIS.com//DTD SQL Map Config 2.0//EN" "http://www.ibatis.com/dtd/sql-map-config-2.dtd"

sqlMapConfig

 
properties resource="conf/sqlMap-config.properties"/

 
settings 
cacheModelsEnabled="true"