|
View:
New views
16 Messages
—
Rating Filter:
Alert me
|
|
|
<generate> tag not workingHi there,
I'm trying to use parameterMaps with the <generate> tag, but it is not working. I have a databse with table 'test_table' and 2 colums: id & name <resultMaps> <resultMap id="TestResult" class="Test"> <result property="ID" column="id" /> <result property="Name" column="name" /> </resultMap> </resultMaps> <parameterMaps> <parameterMap id="insert" class="Test"> <result property="Name" column="name" /> </parameterMap> <parameterMap id="update" class="Test" extends="insert"> <result property="ID" column="id" /> </parameterMap> </parameterMaps> <statements> <!--Insert description--> <insert id="Insert" parameterMap="insert"> <selectKey property="ID" type="post" resultClass="int"> select LAST_INSERT_ID() as value </selectKey> <generate table="test_table" /> </insert> <update id="Update" parameterMap="update"> <generate table="test_table" by="id" /> </update> </statements> </sqlMap> the first error occurs when I try to configure Ibatis (first use). "Specified argument was out of the range of valid values.\r\nParameter name: index". This happens in de update tag. When I comment this generate tag out, the configuration succeeds. Why is this happening, I don't have any parameter that is named 'index'. Secondly, when I try to execute the insert statement, it fails with the message dat column 'name' has no default value. After some debugging, I saw that ibatis generated the next insert statement: "INSERT INTO test_table () VALUES ()", while it should be: "INSERT INTO test_table (name) VALUES (something_here?)" Why is this happening? |
|
|
Re: <generate> tag not workingWell,
One thing I notice that is wrong is your using a result element in your parameter Maps. Instead of this: <parameterMap id="insert" class="Test"> <result property="Name" column="name" /> </parameterMap> Try this: <parameterMap id="insert" class="Test"> <parameter property="Name" column="name" /> </parameterMap> On Tue, Sep 1, 2009 at 6:07 AM, dannystommen <danny@...> wrote:
-- Michael J. McCurrey Read with me at http://www.mccurrey.com http://chaoticmindramblings.blogspot.com/ |
|
|
Re: <generate> tag not workingThanks for your fast reply. I changed it, but the result is still the same incorrect sql statement
|
|
|
Re: <generate> tag not workingWhat version of iBatis?
On Tue, Sep 1, 2009 at 8:12 AM, dannystommen <danny@...> wrote:
-- Michael J. McCurrey Read with me at http://www.mccurrey.com http://chaoticmindramblings.blogspot.com/ |
|
|
Re: <generate> tag not workingVersion 1.6.1
|
|
|
Re: <generate> tag not workingCan you update to 1.6.3 and see if it works, if not, send me your updated map file and I'll take a look. Did you change the <result for both your insert and your update map?
On Tue, Sep 1, 2009 at 8:18 AM, dannystommen <danny@...> wrote:
-- Michael J. McCurrey Read with me at http://www.mccurrey.com http://chaoticmindramblings.blogspot.com/ |
|
|
Re: <generate> tag not workingI think I meant 1.6.2, 1.6.3 is in the works..
On Tue, Sep 1, 2009 at 8:22 AM, Michael McCurrey <mmccurrey@...> wrote: Can you update to 1.6.3 and see if it works, if not, send me your updated map file and I'll take a look. Did you change the <result for both your insert and your update map? -- Michael J. McCurrey Read with me at http://www.mccurrey.com http://chaoticmindramblings.blogspot.com/ |
|
|
Re: <generate> tag not workingWhere can 1.6.3 be found? On ibatis.apache.org I can only find 1.6.2. I upgraded to this version. Still doesn't work
My XML <?xml version="1.0" encoding="UTF-8"?> <sqlMap namespace="Test" xmlns="http://ibatis.apache.org/mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://ibatis.apache.org/mapping ../Config/SqlMap.xsd "> <resultMaps> <resultMap id="TestResult" class="Test"> <result property="ID" column="id" /> <result property="Name" column="name" /> </resultMap> </resultMaps> <parameterMaps> <parameterMap id="insert" class="Test"> <paramater property="Name" column="name" /> </parameterMap> <parameterMap id="update" class="Test" extends="insert"> <paramater property="ID" column="id" /> </parameterMap> </parameterMaps> <statements> <insert id="Insert" parameterMap="insert"> <selectKey property="ID" type="post" resultClass="int"> select LAST_INSERT_ID() as value </selectKey> <generate table="test_table" /> </insert> <update id="Update" parameterMap="update"> <generate table="test_table" by="id"></generate> </update> </statements> </sqlMap>
|
|
|
Re: <generate> tag not workingI'll take a look at it tonight Danny. Stay tuned.
On Wed, Sep 2, 2009 at 12:02 AM, dannystommen <danny@...> wrote:
-- Michael J. McCurrey Read with me at http://www.mccurrey.com http://chaoticmindramblings.blogspot.com/ |
|
|
Re: <generate> tag not workingMichael, did you manage to take a look at it?
|
|
|
Re: <generate> tag not workingYes, but I should have asked what DB you were using..
Your Insert is might not working because your passing in your Insert map, but your ID Column/Property is defined in your Update Map. I also noticed that your column's and properties have different casing in them. There seems to be a bug in Generate in that its ignoring your parametermap to do the conversion between Property and Column. For a workaround, set your property to the same casing as the column or vice-versa. I will address this in 1.6.3 On Thu, Sep 3, 2009 at 2:25 AM, dannystommen <danny@...> wrote:
-- Michael J. McCurrey Read with me at http://www.mccurrey.com http://chaoticmindramblings.blogspot.com/ |
|
|
Re: <generate> tag not workingDatabase: MySQL 5.1 That's because the id column is AutoIncrement. That means that the generated SQL should be "INSERT INTO test_table (name) VALUES (#name)", but it is INSERT INTO test_table() VALUES ()". So the name property isn't used. I changed the casing in both Property as Column to lower, but still doesn't work |
|
|
Feature request: include inside iterateHi,
I've never felt the urge of having the tag <include refid=.... inside an iterate tag. Well I have a complex query where I have to UNION ALL a series of subqueries and finally apply a general ORDER BY. I'm used to group all the select field names in a sql tag and then have select statements like this one: SELECT <include refid="SelectFields" /> FROM .... Now, I implemented the union ALL throught out an iterate tag which does not support the include. which is a pity, isn't it? -- AndreaT --------------------------------------------------------------------- To unsubscribe, e-mail: user-cs-unsubscribe@... For additional commands, e-mail: user-cs-help@... |
|
|
Re: Feature request: include inside iterateyes. that is a good one.
On Mon, Sep 21, 2009 at 11:58 PM, Andrea Tassinari <andreaml@...> wrote: Hi, -- Michael J. McCurrey Read with me at http://www.mccurrey.com http://chaoticmindramblings.blogspot.com/ |
|
|
Re: Feature request: include inside iterateWhat exactly has this to do with my problem?
|
|
|
Re: Feature request: include inside iterateSorry my fault.
Andrea dannystommen wrote: > What exactly has this to do with my problem? > > > Michael McCurrey-3 wrote: >> yes. that is a good one. >> >> On Mon, Sep 21, 2009 at 11:58 PM, Andrea Tassinari < >> andreaml@...> wrote: >> >>> Hi, >>> >>> I've never felt the urge of having the tag <include refid=.... inside an >>> iterate tag. Well I have a complex query where I have to UNION ALL a >>> series >>> of subqueries and finally apply a general ORDER BY. I'm used to group all >>> the select field names in a sql tag and then have select statements like >>> this one: >>> >>> SELECT <include refid="SelectFields" /> >>> FROM .... >>> >>> Now, I implemented the union ALL throught out an iterate tag which does >>> not >>> support the include. which is a pity, isn't it? >>> >>> >>> -- >>> AndreaT >>> >>> --------------------------------------------------------------------- >>> To unsubscribe, e-mail: user-cs-unsubscribe@... >>> For additional commands, e-mail: user-cs-help@... >>> >>> >> >> -- >> Michael J. McCurrey >> Read with me at http://www.mccurrey.com >> http://chaoticmindramblings.blogspot.com/ >> >> > -- AndreaT --------------------------------------------------------------------- To unsubscribe, e-mail: user-cs-unsubscribe@... For additional commands, e-mail: user-cs-help@... |
| Free embeddable forum powered by Nabble | Forum Help |