ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ben Shory" <be...@sapiens.com>
Subject RE: Custom vendor specific Queries
Date Thu, 30 Apr 2009 09:17:21 GMT
i had to accomplish the same thing.
 
please see post on the issue:
 

On Mon, Jan 12, 2009 at 10:41 AM, Ben Shory <ben.s@sapiens.com> wrote:

> Since I'm trying to make it transparent as possible for the DBAs I 

> decided to create a plugin Which modifies all the DAO generated 

> methods to be like this for

> example:

>

> Integer count = (Integer)

> getSqlMapClientTemplate().queryForObject(getStmtId("table.ibatorgenera

> te

> d_countByExample"), example);

>

> ^^^^^^^^^^^

> This plugin also sets a custom super class which implments getStmtId -


> something like this:

>

> protected String getStmtId(String stmtId) {

> initStmtsIfNeeded();

> if(stmts.containsKey("specific-"+stmtId)) {

> return "specific-"+stmtId;

> }

> return stmtId;

> }

>

> Now my DBAs / clients may just drop-in their custom SQL with the 

> naming convention of specific-{table} for the sqlmap namespace

>

> To determine if the statement exsits I had to downcast to 

> SqlMapClientImpl, hope it's not too much of bad practice..

>

> Thanks.

>

>

> -----Original Message-----

> From: Jeff Butler [mailto:jeffgbutler@gmail.com
<mailto:jeffgbutler@gmail.com> ]

> Sent: Monday, January 12, 2009 6:27 PM

> To: user-java@ibatis.apache.org

> Subject: Re: SQL selector

>

> iBATIS does not have a simple API for determining if a statement 

> exists

> - so there's some difficulty with this idea.

>

> This reminds me of the design principle "prefer polymorphism over 

> instanceof". It seems to me that you could extend a generic DAO 

> implementation with a vendor specific implementation and override just


> the methods that have vendor specific SQL. You would also have to 

> configure Spring so that you could pull out the vendor specific 

> implementation that you need. This seems easier to me - but I may not 

> understand the entirety of what you're trying to accomplish.

>

> Jeff Butler

>

> On Mon, Jan 12, 2009 at 3:19 AM, Ben Shory <ben.s@sapiens.com> wrote:

>> It might be better to write a plugin that manipulates the generated 

>> method?

>>

>> -----Original Message-----

>> From: Ben Shory [mailto:ben.s@sapiens.com <mailto:ben.s@sapiens.com>
]

>> Sent: Monday, January 12, 2009 11:13 AM

>> To: user-java@ibatis.apache.org

>> Subject: SQL selector

>>

>> Hi,

>> Before any statement execution, I would like to first check if it has


>> a vendor specific implementation and execute it if so or the default 

>> one if not.

>> My DAOs are generated as spring dao with ibator.

>> I thought of doing something like -

>>

>> String stmtId = "table"+spec_postfix+".countByExample";

>> if(!statementExists(stmtId)) {

>> stmtId = "table.countByExample";

>> }

>> Integer count = (Integer)

>> getSqlMapClientTemplate().queryForObject(stmtId,

>> example);

>> return count;

>>

>> Is this a good approach?

>> Would I have to override SpringDAOTemplae?

>>

>>

>

 


________________________________

From: Nathan Maves [mailto:nathan.maves@gmail.com] 
Sent: Wednesday, April 29, 2009 6:36 AM
To: user-java@ibatis.apache.org
Subject: Re: Custom vendor specific Queries


There is nothing in ibatis that will do this.  this people can usually
be solved at build time by including the sqlmaps that you need to bundle
with your app.


On Sun, Apr 19, 2009 at 2:41 PM, Saloucious <saloucious@gmail.com>
wrote:



	Hello,
	
	i would like to know if it is possible to create custom
workaround queries
	for specific vendors.
	
	Something like  :
	
	<sqlMap resource="sql/Person.xml"/>
	<sqlMap resource="sql/sqlserver/Person.xml"/>
	
	where sql/sqlserver/Person.xml override queries defined in
sql/Person.xml
	
	Thanks
	--
	View this message in context:
http://www.nabble.com/Custom-vendor-specific-Queries-tp23127179p23127179
.html
	Sent from the iBATIS - User - Java mailing list archive at
Nabble.com.
	
	



Mime
View raw message