Re: Way to use sql in mapper interface, without having to create a corresponding xml mapping file?
On Thu, May 13, 2010 at 4:50 PM, Larry Meadors larry.mead...@gmail.comwrote: He wants to represent that in the xml config. Right. It seems odd that you can manually add the Mapper through Java (as Jeff has shown), but not through the xml config.
Re: Way to use sql in mapper interface, without having to create a corresponding xml mapping file?
Ok, cool maybe ill just change to this. (By the way, I'm searching the archives for this, and it's sort of off-topic but since you mentioned you create your datasource in XML - I'm curious how do you declare the pool implementation that you want to use? I know ibatis comes with a default one (not sure which one) but I was going to use the latest commons-dbcp pool.) On Thu, May 13, 2010 at 7:25 PM, Clinton Begin clinton.be...@gmail.comwrote: That would be a really simple change. What I've been really getting used to though is configuring the datasource in XML, and then using Java for most everything else. For example, I have this in a class called IbatisConfig: final String resource = com/myapp/data/IbatisConfig.xml; final Reader reader = Resources.getResourceAsReader(resource); final SqlSessionFactory sessionFactory = new SqlSessionFactoryBuilder().build(reader); final Configuration configuration = sessionFactory.getConfiguration(); TypeAliasRegistry typeAliasRegistry = configuration.getTypeAliasRegistry(); typeAliasRegistry.registerAlias(User.class); typeAliasRegistry.registerAlias(Project.class); typeAliasRegistry.registerAlias(Category.class); typeAliasRegistry.registerAlias(Type.class); configuration.addMapper(UserMapper.class); configuration.addMapper(ProjectMapper.class); configuration.addMapper(SessionMapper.class); return sessionFactory; Clinton On Thu, May 13, 2010 at 5:10 PM, Rick R ric...@gmail.com wrote: On Thu, May 13, 2010 at 4:50 PM, Larry Meadors larry.mead...@gmail.comwrote: He wants to represent that in the xml config. Right. It seems odd that you can manually add the Mapper through Java (as Jeff has shown), but not through the xml config. -- Rick R
Re: Way to use sql in mapper interface, without having to create a corresponding xml mapping file?
On Thu, May 13, 2010 at 9:21 PM, Rick R ric...@gmail.com wrote: (By the way, I'm searching the archives for this, and it's sort of off-topic but since you mentioned you create your datasource in XML - I'm curious how do you declare the pool implementation that you want to use? I know ibatis comes with a default one (not sure which one) but I was going to use the latest commons-dbcp pool.) Nevermind.. Screw it. I'm doing the whole thing now manually with Java (including the BasicDataSource setup) and no xml (just some db properties files). I
Way to use sql in mapper interface, without having to create a corresponding xml mapping file?
Larry showed me his cool no xml config setup which I'd love to implement at some point. For this current project using ibatis3 it's too late to refactor a real lot at this stage and we're using your typical sqlMapConfig file. Overall we still prefer to code all of our sql in xml files, but I just recently decided to create some sql using the annotation-based approach in an interface mapper file. The problem (?) is that even though all the sql is in this mapper interface, I seem to still have to declare a dummy corresponding mapping xml file just to declare the interface namespace (otherwise ibatis at runtime bitches about not being able to find the mapping.) I looked over the ibatis3 pdf and under the annotation approach section for using Mappers it doesn't really mention that you need the corresponding mapping.xml file, so I'm probably just missing something stupid? Shouldn't there be a way in the SqlMapConfig to declare Use this interface mapper ? Basically I was thinking in the mapper section of the config instead of having to use: mappers mapper resource=mapper-files/metadb/DataReleaseMapper.xml/ You could also include: mappers mapper class=com.foobar.mapper.DataReleaseMapper/ As it is now, I'm having to declare that silly DataReleaseMapper.xml which only ends up wrapping my interface Mapper. ?xml version=1.0 encoding=UTF-8 ? !DOCTYPE mapper PUBLIC -//ibatis.apache.org//DTD Mapper 3.0//EN http://ibatis.apache.org/dtd/ibatis-3-mapper.dtd; mapper namespace=com.foo.dataselector.media.service.mapper.DataReleaseMapper /mapper My assumption is that I'm missing something obvious:)
what happened to queryForMap?
I really though queryForMap was cool. I'm looking for how to do it in ibatis3 but don't see a way. Doesn't seem to exist as a select type on the Session (and don't see it in the docs.) Was it canned in ibatis3, if so, just curious why? (Granted it's not hard to build a Map in java after I get my list, but hey it was one less step I had to do using ibatis queryForMap) -- Rick R
Re: what happened to queryForMap?
On Fri, Mar 19, 2010 at 8:08 PM, Clinton Begin clinton.be...@gmail.comwrote: It was liquidated. Honestly I thought it was messy... but maybe I underestimated its usefulness... Well, most times I'm using it are for when I have a nested structure defined defined by a parentID column in the same table and you can have n umber of nodes in your tree. I get too lazy trying to figure out how to get an ibatis map populated n-levels deep of nested nodes, so I typically just return a map of all values... key: id, value: thObject. Then I just go and manually iterate over the values of the map and add if it has a parentID I find the parent in the map by id and then it as child to the parent. Seem to work pretty well, but maybe there's a more efficient way to build up a tree?
why is ibatis rolling up for an association, not sure why this isn't flat, or what its rolling up on?
I'm now starting to get into using ibatis3 more and I'm curious about why a 'roll up' is happening (based on a column I didn't mention as a rollup column) when I use an association. I'm sure it's something stupid I'm missing but I don't see it. For example this flat structure works just fine, and its what I've used in ibatis2 for a simple flat structure: resultMap id=ProdAttrGroupAttrValueResultWithAttributeValue type=ProdAttrGroupAttrValue result column=defaultValueFlag property=defaultValueFlag jdbcType=CHAR / result column=objectType property=objectType jdbcType=VARCHAR / result column=parentValueID property=parentValueID jdbcType=INTEGER / !-- the ProAttrGroupAttrValue has an attributeValue object property: -- result property=attributeValue.attributeValueID column=attributeValueID/ result column=value property=attributeValue.value jdbcType=VARCHAR/ result column=attributeValueDesc property=attributeValue.attributeValueDesc jdbcType=VARCHAR / result column=requiredFlag property=attributeValue.requiredFlag jdbcType=CHAR / /resultMap But I thought I should follow ibatis3 conventions and use an association to make it more clear: resultMap id=ProdAttrGroupAttrValueResultWithAttributeValue type=ProdAttrGroupAttrValue result column=defaultValueFlag property=defaultValueFlag jdbcType=CHAR / result column=objectType property=objectType jdbcType=VARCHAR / result column=parentValueID property=parentValueID jdbcType=INTEGER / !-- using an association instead -- association property=attributeValue column=attributeValueID javaType=AttributeValue id property=attributeValueID column=attributeValueID/ result column=value property=value jdbcType=VARCHAR/ result column=attributeValueDesc property=attributeValueDesc jdbcType=VARCHAR / result column=requiredFlag property=requiredFlag jdbcType=CHAR / /association /resultMap However, when I use the latter association approach I end up getting rows completely thrown out, but I'm not sure why and/or what logic its using. The query returns 13 rows, but I only end up with 7 objects in the latter association approach.. DEBUG [main] java.sql.PreparedStatement debug- == Parameters: 2(Integer), 12(Integer), 100(Integer) DEBUG [main] java.sql.ResultSet debug- ==Columns: parentValueID, objectType, defaultValueFlag, attributeValueID, value, attributeValueDesc, requiredFlag DEBUG [main] java.sql.ResultSet debug- ==Row: 15282, Checkbox, Y, 9042, AA, US AA %, N DEBUG [main] java.sql.ResultSet debug- ==Row: 15282, Checkbox, N, 9043, GAA, US GAA %, N DEBUG [main] java.sql.ResultSet debug- ==Row: 9043, Checkbox, N, 12059, nonOrderedGAATelecasts, Allow Non Ordered GAA, N DEBUG [main] java.sql.ResultSet debug- ==Row: 15282, Checkbox, N, 12371, cvgAApercent, CVG AA %, N DEBUG [main] java.sql.ResultSet debug- ==Row: 15282, Checkbox, N, 13260, cvgGAApercent, CVG GAA %, N DEBUG [main] java.sql.ResultSet debug- ==Row: 12524, Checkbox, N, 9044, HUT/Share, US HUT/PUT and Share %, N DEBUG [main] java.sql.ResultSet debug- ==Row: 12524, Checkbox, N, 9063, MAMI, Median Age / Median Income, N DEBUG [main] java.sql.ResultSet debug- ==Row: 15298, Checkbox, N, 15299, indexP2, Index % P2+, N DEBUG [main] java.sql.ResultSet debug- ==Row: 15298, Checkbox, N, 15304, CVG_Index_P18_plus, CVG Index % P18+, N DEBUG [main] java.sql.ResultSet debug- ==Row: 12396, Checkbox, N, 12391, Commercial, National Commercial Statistics, N DEBUG [main] java.sql.ResultSet debug- ==Row: 15284, Checkbox, N, 9064, RGL, Reach, Gain/Loss, N DEBUG [main] java.sql.ResultSet debug- ==Row: 15284, Checkbox, N, 11135, vcrContribution, VCR Contribution, N DEBUG [main] java.sql.ResultSet debug- ==Row: 15284, Checkbox, N, 11134, avgMinutesViewed, Average Minutes Viewed, N 13 rows but only 7 Objects using association: DEBUG [main] com.nielsen.dataselector.media.service.TestAttributeGroup testGetStatistics- TestAttributeGroup ProdAttrGroupAttrValue: com.nielsen.dataselector.media.service.model.prodattrgroupattrva...@40e99ce5 [ defaultValueFlag=Y objectType=Checkbox parentValueID=15282 productID=null sequenceNumber=null attributevalue=com.nielsen.dataselector.media.service.model.attributeva...@342f356f [ attributeValueDependencies=null attributeValueID=9042 value=AA attributeValueDesc=US AA % requiredFlag=N ] attributeGroup=null ] DEBUG [main] com.nielsen.dataselector.media.service.TestAttributeGroup testGetStatistics- TestAttributeGroup ProdAttrGroupAttrValue: com.nielsen.dataselector.media.service.model.prodattrgroupattrva...@75d252d[ defaultValueFlag=N objectType=Checkbox parentValueID=15282 productID=null sequenceNumber=null attributevalue=com.nielsen.dataselector.media.service.model.attributeva...@7433b121 [
Re: why is ibatis rolling up for an association, not sure why this isn't flat, or what its rolling up on?
On Sun, Feb 21, 2010 at 8:01 PM, Clinton Begin clinton.be...@gmail.comwrote: It rolls up by id elements, or if none exist, it rolls up by all columns (which is why specifying an id is important). I did provide an id which adds to my confusion. association property=attributeValue column=attributeValueID javaType=AttributeValue id property=attributeValueID column=attributeValueID/ The select is: SELECT aga.parentValueID, aga.objectType, aga.defaultValueFlag, aga.attributeValueID, av.value, av.attributeValueDesc, av.requiredFlag FROM Clinton On Sun, Feb 21, 2010 at 5:55 PM, Rick R ric...@gmail.com wrote: I'm now starting to get into using ibatis3 more and I'm curious about why a 'roll up' is happening (based on a column I didn't mention as a rollup column) when I use an association. I'm sure it's something stupid I'm missing but I don't see it. For example this flat structure works just fine, and its what I've used in ibatis2 for a simple flat structure: resultMap id=ProdAttrGroupAttrValueResultWithAttributeValue type=ProdAttrGroupAttrValue result column=defaultValueFlag property=defaultValueFlag jdbcType=CHAR / result column=objectType property=objectType jdbcType=VARCHAR / result column=parentValueID property=parentValueID jdbcType=INTEGER / !-- the ProAttrGroupAttrValue has an attributeValue object property: -- result property=attributeValue.attributeValueID column=attributeValueID/ result column=value property=attributeValue.value jdbcType=VARCHAR/ result column=attributeValueDesc property=attributeValue.attributeValueDesc jdbcType=VARCHAR / result column=requiredFlag property=attributeValue.requiredFlag jdbcType=CHAR / /resultMap But I thought I should follow ibatis3 conventions and use an association to make it more clear: resultMap id=ProdAttrGroupAttrValueResultWithAttributeValue type=ProdAttrGroupAttrValue result column=defaultValueFlag property=defaultValueFlag jdbcType=CHAR / result column=objectType property=objectType jdbcType=VARCHAR / result column=parentValueID property=parentValueID jdbcType=INTEGER / !-- using an association instead -- association property=attributeValue column=attributeValueID javaType=AttributeValue id property=attributeValueID column=attributeValueID/ result column=value property=value jdbcType=VARCHAR/ result column=attributeValueDesc property=attributeValueDesc jdbcType=VARCHAR / result column=requiredFlag property=requiredFlag jdbcType=CHAR / /association /resultMap However, when I use the latter association approach I end up getting rows completely thrown out, but I'm not sure why and/or what logic its using. The query returns 13 rows, but I only end up with 7 objects in the latter association approach.. DEBUG [main] java.sql.PreparedStatement debug- == Parameters: 2(Integer), 12(Integer), 100(Integer) DEBUG [main] java.sql.ResultSet debug- ==Columns: parentValueID, objectType, defaultValueFlag, attributeValueID, value, attributeValueDesc, requiredFlag DEBUG [main] java.sql.ResultSet debug- ==Row: 15282, Checkbox, Y, 9042, AA, US AA %, N DEBUG [main] java.sql.ResultSet debug- ==Row: 15282, Checkbox, N, 9043, GAA, US GAA %, N DEBUG [main] java.sql.ResultSet debug- ==Row: 9043, Checkbox, N, 12059, nonOrderedGAATelecasts, Allow Non Ordered GAA, N DEBUG [main] java.sql.ResultSet debug- ==Row: 15282, Checkbox, N, 12371, cvgAApercent, CVG AA %, N DEBUG [main] java.sql.ResultSet debug- ==Row: 15282, Checkbox, N, 13260, cvgGAApercent, CVG GAA %, N DEBUG [main] java.sql.ResultSet debug- ==Row: 12524, Checkbox, N, 9044, HUT/Share, US HUT/PUT and Share %, N DEBUG [main] java.sql.ResultSet debug- ==Row: 12524, Checkbox, N, 9063, MAMI, Median Age / Median Income, N DEBUG [main] java.sql.ResultSet debug- ==Row: 15298, Checkbox, N, 15299, indexP2, Index % P2+, N DEBUG [main] java.sql.ResultSet debug- ==Row: 15298, Checkbox, N, 15304, CVG_Index_P18_plus, CVG Index % P18+, N DEBUG [main] java.sql.ResultSet debug- ==Row: 12396, Checkbox, N, 12391, Commercial, National Commercial Statistics, N DEBUG [main] java.sql.ResultSet debug- ==Row: 15284, Checkbox, N, 9064, RGL, Reach, Gain/Loss, N DEBUG [main] java.sql.ResultSet debug- ==Row: 15284, Checkbox, N, 11135, vcrContribution, VCR Contribution, N DEBUG [main] java.sql.ResultSet debug- ==Row: 15284, Checkbox, N, 11134, avgMinutesViewed, Average Minutes Viewed, N 13 rows but only 7 Objects using association: DEBUG [main] com.nielsen.dataselector.media.service.TestAttributeGroup testGetStatistics- TestAttributeGroup ProdAttrGroupAttrValue
Re: why is ibatis rolling up for an association, not sure why this isn't flat, or what its rolling up on?
On Sun, Feb 21, 2010 at 10:50 PM, Clinton Begin clinton.be...@gmail.comwrote: Oh... also put an id element on the parent (likee parentValueID?). Ok that's even more weird now. When I changed: result column=parentValueID property=parentValueID jdbcType=INTEGER / to id property=parentValueID column=parentValueID jdbcType=INTEGER/ I now end up with 6 of the rows mapped to objects (instead of 7 without it .. and remember there should be 13 objects total.) Also, be careful with automapping and nested results. In Beta 9 I added configuration to disable automapping for nested results, only because it was confusing where the results would end up. But that doesn't look like a problem here, as you don't have conflicting property names. I'm curious what part I'm automapping? I thought I was doing it just as I saw in your blog example in the PDF? I even changed it a bit to be more like your example (not that in my case I'd think I would need to get the value of attributeValueID more than once.) SELECT aga.parentValueID, aga.objectType, aga.defaultValueFlag, aga.attributeValueID as parent_avID, av.attributeValueID, av.value, av.attributeValueDesc, av.requiredFlag FROM resultMap id=ProdAttrGroupAttrValueResultWithAttributeValue type=ProdAttrGroupAttrValue id property=parentValueID column=parentValueID jdbcType=INTEGER/ result column=defaultValueFlag property=defaultValueFlag jdbcType=CHAR / result column=objectType property=objectType jdbcType=VARCHAR / !--result column=parentValueID property=parentValueID jdbcType=INTEGER / -- association property=attributeValue column=parent_avID javaType=AttributeValue id property=attributeValueID column=attributeValueID jdbcType=INTEGER/ result column=value property=value jdbcType=VARCHAR/ result column=attributeValueDesc property=attributeValueDesc jdbcType=VARCHAR / result column=requiredFlag property=requiredFlag jdbcType=CHAR / /association /resultMap To Guy's point, not sure if the object's I'm mapping to matter? but if so: public class ProdAttrGroupAttrValue extends BaseModel { private String defaultValueFlag; private String objectType; private Integer parentValueID; private Integer productID; private Integer sequenceNumber; private AttributeValue attributeValue; //the association object I'm trying to populate private AttributeGroup attributeGroup; //not used here //...set/gets public class AttributeValue extends BaseModel { private ListAttributeValue attributeValueDependencies; //not used here in this query private Integer attributeValueID; private String value; private String attributeValueDesc; private String requiredFlag; //... set/gets I'm sure this is going to come down to a typo or something. I can just feel it, because it seems like I'm doing things correctly?
Re: why is ibatis rolling up for an association, not sure why this isn't flat, or what its rolling up on?
On Sun, Feb 21, 2010 at 11:26 PM, Guy Rouillier guyr-...@burntmail.comwrote: On 2/21/2010 11:19 PM, Rick R wrote: To Guy's point, not sure if the object's I'm mapping to matter? but if so: Objects look fine. How are you storing the collection of objects? As a List? Because if you are storing a Hashmap, that may explain some missing objects. Returning them as a List ListProdAttrGroupAttrValue findProdAttrGroupAttrValues(@Param(productID) Integer productID, @Param(attributeGroupID) Integer attributeGroupID, @Param(sampleTypeKey) Integer sampleTypeKey);
Re: why is ibatis rolling up for an association, not sure why this isn't flat, or what its rolling up on?
BaseModel just has some utility things mostly for XStream (I do also have XStream annotations on my model classes, but I wouldn't think that should mess up ibatis?) BaseModel: @Override public String toString() { return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE); } public static T extends BaseModel T createObjectFromXStream(File aFile, Class className) throws Exception { XStream stream = new XStream(new DomDriver()); stream.processAnnotations(className); BufferedReader input = new BufferedReader(new FileReader(aFile)); return (T) stream.fromXML(input); } public static T extends BaseModel T createObjectFromXStream( InputStream istream, Class className) throws Exception { XStream stream = new XStream(new DomDriver()); stream.processAnnotations(className); return (T) stream.fromXML(istream); } On Sun, Feb 21, 2010 at 11:36 PM, Guy Rouillier guyr-...@burntmail.comwrote: On 2/21/2010 11:19 PM, Rick R wrote: To Guy's point, not sure if the object's I'm mapping to matter? but if so: public class ProdAttrGroupAttrValue extends BaseModel { public class AttributeValue extends BaseModel { After sending my last reply, I noticed both your object classes extend BaseModel. What is that? As a test, I'd suggest removing this derivation to ensure that the base class is not doing things to trip you up. One BaseModel I've used is from GXT and that definitely has some restrictions on how it is used. -- Guy Rouillier - To unsubscribe, e-mail: user-java-unsubscr...@ibatis.apache.org For additional commands, e-mail: user-java-h...@ibatis.apache.org -- Rick R
Re: why is ibatis rolling up for an association, not sure why this isn't flat, or what its rolling up on?
And those static methods will be moved to a Helper file:) it's not my code:) On Sun, Feb 21, 2010 at 11:43 PM, Rick R ric...@gmail.com wrote: BaseModel just has some utility things mostly for XStream (I do also have XStream annotations on my model classes, but I wouldn't think that should mess up ibatis?) BaseModel: @Override public String toString() { return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE); } public static T extends BaseModel T createObjectFromXStream(File aFile, Class className) throws Exception { XStream stream = new XStream(new DomDriver()); stream.processAnnotations(className); BufferedReader input = new BufferedReader(new FileReader(aFile)); return (T) stream.fromXML(input); } public static T extends BaseModel T createObjectFromXStream( InputStream istream, Class className) throws Exception { XStream stream = new XStream(new DomDriver()); stream.processAnnotations(className); return (T) stream.fromXML(istream); } On Sun, Feb 21, 2010 at 11:36 PM, Guy Rouillier guyr-...@burntmail.comwrote: On 2/21/2010 11:19 PM, Rick R wrote: To Guy's point, not sure if the object's I'm mapping to matter? but if so: public class ProdAttrGroupAttrValue extends BaseModel { public class AttributeValue extends BaseModel { After sending my last reply, I noticed both your object classes extend BaseModel. What is that? As a test, I'd suggest removing this derivation to ensure that the base class is not doing things to trip you up. One BaseModel I've used is from GXT and that definitely has some restrictions on how it is used. -- Guy Rouillier - To unsubscribe, e-mail: user-java-unsubscr...@ibatis.apache.org For additional commands, e-mail: user-java-h...@ibatis.apache.org -- Rick R -- Rick R
Re: why is ibatis rolling up for an association, not sure why this isn't flat, or what its rolling up on?
On Mon, Feb 22, 2010 at 12:03 AM, Clinton Begin clinton.be...@gmail.comwrote: The reason is that the rows aren't uniquely identified. Upon a second look, I see that the column I recommended isn't unique. Which columns uniquely identify each parent row? They'd be unique by a combination of parentAttributeID and attributeValueID That would make a row unique. So your post led me to try this association property=attributeValue column={parentValueID=parentValueID,attributeValue.attributeValueID=attributeValueID} - but that would only work I suppose if my property was a composite object which its not. Looks like I should stick to not using an association for this (and do it the ibatis2.0 way?): !-- flatten -- result property=parentValueID column=parentValueID jdbcType=CHAR / result property=attributeValue.attributeValueID column=attributeValueID jdbcType=INTEGER/ result column=value property=attributeValue.value jdbcType=VARCHAR/
If all my sql is in xml, do I gain that much (assuming unit tests) using Mapper objects as well?
This probably has been brought up before, but a quick search on nabble didn't return anything that useful at the moment... Our plan is to have ALL sql in the mapper xml files (not annotations.) It 'seems' like the only real benefit we'd then get out of also providing a corresponding mapper object is for IDE support and catching of any invalid calls early on (and maybe refactoring is slightly cleaner but that's debatable.) But assuming we have a unit test for every mapper sql command in our service layer, is there anything else I miss by skipping the whole creation of mapper objects and simply going after the sql the old way... session.update(fooBar.updateEmployee, obj) ? (I read pages 53/54 of the guide and nothing jumped out at me as a huge gain in our case using Mapper classes.) I just don't want to be overlooking anything. -- Rick R
Re: If all my sql is in xml, do I gain that much (assuming unit tests) using Mapper objects as well?
On Wed, Feb 17, 2010 at 2:51 PM, Jeff Butler jeffgbut...@gmail.com wrote: Using a mapper interface means you have a bit less code to write How is it less code?, that's my whole point in dropping it since I think it adds more code (for in our case seemingly little gain.) All my sql is in xml and for every mapper xml statement I create I have to go over and add a Mapper interface method. It's just one more piece of code that needs attention.
Re: If all my sql is in xml, do I gain that much (assuming unit tests) using Mapper objects as well?
On Wed, Feb 17, 2010 at 4:09 PM, Jeff Butler jeffgbut...@gmail.com wrote: In my case, it's a bit less code: Mapper interface: ListMyObject getByCompoundKey(@Param(id1) Integer id1, @Param(id2) Integer id2); Ah I see. That's an excellent point! I hadn't thought of that. In our case 99% of the parms will be coming in through a single pojo type being passed to the query, but I can totally see how the above would be extremely useful.
now with ibatis3 - which sybase driver? - because of this issue
Using the standard jconn3 sybase driver (the jtds driver is fine), I'm getting this error when attempting to get a List the following way without only adding default stuff (username, etc) SqlSession session = SqlSessions.metaDbSessionFactory.openSession(); SampleMapper mapper = session.getMapper(SampleMapper.class); try { return mapper.getSamples(); } finally { session.close(); } with jconn3 causes: org.apache.ibatis.exceptions.IbatisException: ### Error closing transaction. Cause: org.apache.ibatis.transaction.TransactionException: Error configuring AutoCommit. Your driver may not support getAutoCommit() or setAutoCommit(). Cause: com.sybase.jdbc3.jdbc.SybSQLException: SET CHAINED command not allowed within multi-statement transaction. ### Cause: org.apache.ibatis.transaction.TransactionException: Error configuring AutoCommit. Your driver may not support getAutoCommit() or setAutoCommit(). Cause: com.sybase.jdbc3.jdbc.SybSQLException: SET CHAINED command not allowed within multi-statement transaction. Using the jtds driver things are fine. After googling for a while I found some info related to sybase and this issue https://forum.hibernate.org/viewtopic.php?f=1t=930864start=0 And at the bottom of that post I did what was mentioned and when I set the datasource with: SERVER_INITIATED_TRANSACTIONS, false And THINGS WORKED! BUT, my question is what drawback does this have and should I consider a different approach to my ibatis queries? Also, why would it think it's doing a multi-statement transaction? The query is just: sql id=sampleSql select sampleTypeKey, sampleDesc from Sample /sql select id=getSamples resultType=Sample include refid=sampleSql/ order by sequenceNumber /select The sybase docs mention: SERVER_INITIATED_TRANSACTIONS This property allows the server to control transactions. By default, the property is set to true, and jConnect allows the server to start and control transactions by using Transact-SQL® set chained on. If the property is set to false, the transactions are started and controlled by jConnect using transact sql begin tran. Sybase recommends that you allow the server to control the transactions. Default: True - To unsubscribe, e-mail: user-java-unsubscr...@ibatis.apache.org For additional commands, e-mail: user-java-h...@ibatis.apache.org
Re: iBatis 3.0 minimal complete example
On Tue, Feb 2, 2010 at 9:27 AM, Clinton Begin clinton.be...@gmail.comwrote: I agree, that it's long overdue. Perhaps it's time for Jpetstore 6. And without leveraging Guice or Spring :)
Re: iBatis 3.0 minimal complete example
On Wed, Feb 10, 2010 at 11:18 PM, Zoran Avtarovski zo...@sparecreative.com wrote: To be honest I think the choice of front end matters little. The key aspect is the data layer - IB3 and any dependency injection used. I think one example using spring and another using Guice is more than enough. Yea, I don't see why the front end matters at all either, unless you plan on demonstrating the handling the transaction demarcation in the servlet layer of a webapp.I like to have all my ibatis stuff in its own self contained jar since I never know what's going to end up using it within the company so I handle all my transactions closer to the fire. [OT]: Concerning the DI stuff, yea yea I know I'm in the minority that thinks DI is way over rated. I like the aspect oriented parts of things like Spring and Guice (transaction demarcation), but for pure DI (injecting an implementation) I still don't get all the hype. Yes, I know it's supposed to help with testing, which actually seems to be the ONLY place people seem to ever mention its primary use, but even there I guess I'm lazy since I don't care about sending in mock objects to my java persistence methods. Not that I don't test, I just suppose I don't test down to the level of mock objects. I want to be sure my ibatis services work though - so for that just using a different datasource in my properties file suffices. (The other area I could see it helping a bit is if you need to compile different builds with different implementations - you could have different xml files that get used for doing your builds. How common is this though - certainly not very.) Feel free to let me know off-list how DI has 'really' helped - not some mythical Spinal Tap Well this one goes to 11 argument. - To unsubscribe, e-mail: user-java-unsubscr...@ibatis.apache.org For additional commands, e-mail: user-java-h...@ibatis.apache.org