dealing with multiple databases?
Hi, I am about to deploy a massive webapplication which uses ibatis. My database is designed to be partioned into separate clusters for maximum scalability so I will eventually need a way to dynamically set the datasource ibatis is using on a per request basis based on a ClusterId. Right now ibatis does not seem to provide any mechanism for swapping datasources/managing multiple datasources in the same sqlmap. I was curious if anyone has attempted this, or if anyone has any suggestions before I get started hacking away. I suspect I will have to create my own DataSource implementation but I was curious if anyone has already done something similar? Thanks, Kris
Adding additional logic to DAO objects
My application makes heavy use of the ibatis DAO framework. I primarily use sqlmaps for my implementation. The problem is, my app has some front end caching that needs to be flushed when underlying data is changed. It seems like the best place to do this is in the DAOs however I have no way of passing any context to the dao objects. I don't want to add parameters to all the methods just so I can pass some context which should already be there.Is there any wayto create/extend an existing DAOManager? Ideally I would like to extend the sqlmaps dao manager some how such that I can keep a reference to my cache and make it accessible to the DAOs so that it can be flushed as appropriate.Thanks, Kris
Re: n+1 is triggering multiple queries, 3?
Thanks Clinton, I will look into this myself when I have more time. I wish there were a MySql Profiler or something so that I could see what queries are actually being executed. Maybe I will step into your code if I get a chance. KrisClinton Begin [EMAIL PROTECTED] wrote: Kris,This is the right list ([EMAIL PROTECTED]).Sorry nobody responded. I had a quick look when you originally sent it, and I couldn't see how it was possible that the groupBy or a nested resultMap could cause additional queries...Perhaps someone else has thoughts? If not, you might have to write an isolated unit test and submit it through JIRA.Cheers,Clinton On 7/9/05, Kris Rasmussen [EMAIL PROTECTED] wrote: I have an n+1 mapping. When I look at mysql health in the administrator it apears that 3 queries are being executed instead of one. The first query gets executed when I retrieve the intial object via queryForObject. The next two queries are being executed when I attempt to access the List which stores the related objects from the main object. I am very curious what is going on since I don't know how Ibatis could even know what query to execute to get the items later? The following maps are used to retrive a single instance of classB with all of its classA children stored in one of its properties which is of course a list. resultMap id="getClassAResult" class="classA" ... some basic properties /resultMap resultMap id="getClassBResult" class="classB" result property="primKey1" column="classB.primKey1"/ result property="primKey2" column="classB.primKey2"/ ... some more properties /resultMap resultMap id="getClassBWithClassAsResult" class="classB" extends="getClassBResult" groupBy="primKey1,primKey2" result property="classAs" resultMap="namespace.getClassAResult"/ /resultMap and my select statement... select id="getClassBWithClassAs" parameterClass="keyClass" resultMap="getClassBWithClassAsResult" SELECT classB.*,classA.* FROM classB ,classA WHERE classB.primKey1=#primKey1# AND classB.primKey2=#primKey2# AND gallery_image.SiteId=#siteId# AND gallery_image.BlockId=#blockId# GROUP BY classB.primKey1,classB.primKey2,classA.primKey3 /select __Do You Yahoo!?Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com Start your day with Yahoo! - make it your home page
n+1 is triggering multiple queries, why???
I think I sent this message to the wrong list originally. I would really appreciate it if someone could shed some light on the issue. I must be doing something wrong? Read below, thanks! Kris Rasmussen [EMAIL PROTECTED] wrote: Date: Sat, 9 Jul 2005 02:36:04 -0700 (PDT)From: Kris Rasmussen [EMAIL PROTECTED]Subject: n+1 is triggering multiple queries, 3?To: user-java@ibatis.apache.org I have an n+1 mapping. When I look at mysql health in the administrator it apears that 3 queries are being executed instead of one. The first query gets executed when I retrieve the intial object via queryForObject. The next two queries are being executed when I attempt to access the List which stores the related objects from the main object. I am very curious what is going on since I don't know how Ibatis could even know what query to execute to get the items later? The following maps are used to retrive a single instance of classB with all of its classA children stored in one of its properties which is of course a list. resultMap id="getClassAResult" class="classA" ... some basic properties /resultMap resultMap id="getClassBResult" class="classB" result property="primKey1" column="classB.primKey1"/ result property="primKey2" column="classB.primKey2"/ ... some more properties /resultMap resultMap id="getClassBWithClassAsResult" class="classB" extends="getClassBResult" groupBy="primKey1,primKey2" result property="classAs" resultMap="namespace.getClassAResult"/ /resultMap and my select statement... select id="getClassBWithClassAs" parameterClass="keyClass" resultMap="getClassBWithClassAsResult" SELECT classB.*,classA.* FROM classB ,classA WHERE classB.primKey1=#primKey1# AND classB.primKey2=#primKey2# AND gallery_image.primKey1=#primKey1# AND classA.primKey2=#primKey2# GROUP BY classB.primKey1,classB.primKey2,classA.primKey3 /select __Do You Yahoo!?Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com Sell on Yahoo! Auctions - No fees. Bid on great items.
n+1 is triggering multiple queries, 3?
I have an n+1 mapping. When I look at mysql health in the administrator it apears that 3 queries are being executed instead of one. The first query gets executed when I retrieve the intial object via queryForObject. The next two queries are being executed when I attempt to access the List which stores the related objects from the main object. I am very curious what is going on since I don't know how Ibatis could even know what query to execute to get the items later? The following maps are used to retrive a single instance of classB with all of its classA children stored in one of its properties which is of course a list. resultMap id="getClassAResult" class="classA" ... some basic properties /resultMap resultMap id="getClassBResult" class="classB" result property="primKey1" column="classB.primKey1"/ result property="primKey2" column="classB.primKey2"/ ... some more properties /resultMap resultMap id="getClassBWithClassAsResult" class="classB" extends="getClassBResult" groupBy="primKey1,primKey2" result property="classAs" resultMap="namespace.getClassAResult"/ /resultMap and my select statement... select id="getClassBWithClassAs" parameterClass="keyClass" resultMap="getClassBWithClassAsResult" SELECT classB.*,classA.* FROM classB ,classA WHERE classB.primKey1=#primKey1# AND classB.primKey2=#primKey2# AND gallery_image.SiteId=#siteId# AND gallery_image.BlockId=#blockId# GROUP BY classB.primKey1,classB.primKey2,classA.primKey3 /select__Do You Yahoo!?Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com