You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by cowwoc <co...@bbs.darktech.org> on 2010/04/05 18:38:26 UTC
SqlSession.close() without committing
Hi,
What happens if I close() a SqlSession without committing? Does
iBatis guarantee that the transaction will roll back? I ask because I
want to use the following pattern:
SqlSession session = factory.openSession();
try
{
// do work
session.commit();
}
finally
{
session.close();
}
If no exception is thrown, the session gets committed. Otherwise,
it is rolled back without having to catch exceptions and explicitly roll
back.
Thanks,
Gili
---------------------------------------------------------------------
To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
For additional commands, e-mail: user-java-help@ibatis.apache.org
Re: [IBatis3-beta10] nested results for collection
Posted by Viv Kapadekar <vi...@peoplepowerco.com>.
Sure, I can. BTW in the User Guide on Page 38 I see this
Nested Select for Collection
First, let’s look at using a nested select to load the Posts for the
Blog.
<resultMap id=”blogResult” type=”Blog”>
<collection property="posts" javaType=”ArrayList” column="blog_id"
ofType="Post" select=”selectPostsForBlog”/>
</resultMap>
<select id=”selectBlog” parameterType=”int” resultMap=”blogResult”>
SELECT * FROM BLOG WHERE ID = #{id}
</select>
<select id=”selectPostsForBlog” parameterType=”int” resultType="Author">
SELECT * FROM POST WHERE BLOG_ID = #{id}
</select>
Should it be Post instead?
Thanks
--V
On Apr 7, 2010, at 11:51 AM, Clinton Begin wrote:
> Weird that an error was not thrown in that case... I'll have a look
> to see why this condition would go ignored.
>
> Thanks for tracking the defect down. If you get a chance, copy this
> message into a Jira defect.
>
> Clinton
>
> On Wed, Apr 7, 2010 at 12:41 PM, Viv Kapadekar <vivek@peoplepowerco.com
> > wrote:
> Ah, found it. The column attribute was missing from Collection.
> Added that and it worked.
>
>
>> <collection property="carParts" column="id" javaType="ArrayList"
>> ofType="Parts" select="getCarPartInfo"/>
>
>
> 2010-04-07 11:38:47,254 DEBUG [iBatisImplTest] Car id 1 name Audi
> 2010-04-07 11:38:47,255 DEBUG [iBatisImplTest] car Part iterator is
> not null 3
> 2010-04-07 11:38:47,255 DEBUG [iBatisImplTest] Car Part index 100
> Name door
> 2010-04-07 11:38:47,255 DEBUG [iBatisImplTest] Car Part index 101
> Name windshield
> 2010-04-07 11:38:47,256 DEBUG [iBatisImplTest] Car Part index 102
> Name Brakes
>
>
>
>> Hi Clinton
>>
>> Basically what I am seeing is the nested select is not getting
>> executed. To make it simpler, I created a simple prototype. I know
>> in this example I don't need to create a separate select, but
>> wondering why its not working. Here are the details
>>
>> POJOs
>> public class Car
>> {
>> private int carId ;
>> private String name ;
>>
>> private List<Parts> carParts ;
>> }
>>
>>
>> public class Parts
>> {
>> private int partId;
>> private String name ;
>> }
>>
>> ==============
>> Mapper
>>
>> <resultMap id="carResult" type="Car">
>> <id property="carId" column="id"/>
>> <result property="name" column="name"/>
>> <collection property="carParts" javaType="ArrayList"
>> ofType="Parts" select="getCarPartInfo"/>
>> </resultMap>
>>
>> <select id="getCarsInfo" resultMap="carResult">
>> SELECT car_id as "id", name
>> FROM Car where car_id=1
>> </select>
>>
>> <select id="getCarPartInfo" resultType="Parts">
>> SELECT part_id as "partId", name
>> FROM Parts where car_id=1
>> </select>
>> ==========
>> Tables
>> ======
>>
>>
>> mysql> select * from car;
>> +--------+------+
>> | car_id | name |
>> +--------+------+
>> | 1 | Audi |
>> +--------+------+
>> 1 row in set (0.00 sec)
>>
>>
>> mysql> select * from Parts;
>> +---------+------------+--------+
>> | part_id | name | car_id |
>> +---------+------------+--------+
>> | 100 | door | 1 |
>> | 101 | windshield | 1 |
>> | 102 | Brakes | 1 |
>> +---------+------------+--------+
>> 3 rows in set (0.00 sec)
>>
>>
>> =========================
>>
>> Unit Test
>>
>> public void testGetCarInfo() {
>> List<Car> list = repository.getCarsInfo();
>> for (Iterator<Car> carIter = list.iterator();carIter.hasNext();) {
>> Car d = carIter.next();
>> logger.debug("Car id " + d.getCarId() + " name " + d.getName());
>> List<Parts> dPartList = d.getCarParts();
>> if (dPartList!=null) {
>> logger.debug(" car Part iterator is not null " +
>> dPartList.size());
>> } else {
>> logger.debug(" car Part List is null " );
>> }
>>
>> }
>>
>> assertNotNull("At least one device must exist", list);
>> }
>>
>>
>>
>> Unit Test Result
>>
>> 2010-04-07 11:27:11,576 DEBUG [iBatisImplTest] Car id 1 name Audi
>> 2010-04-07 11:27:11,577 DEBUG [iBatisImplTest] car Part List is
>> null
>>
>>
>> As you can see the result does not contain the Parts List, the
>> Collection is not getting set. What is missing?
>>
>> -V
>>
>>
>>
>>
>>
>> On Apr 6, 2010, at 8:49 PM, Clinton Begin wrote:
>>
>>> So you have desc in two places? This is getting more confusing.
>>> Maybe post the expected result set and the classes you're mapping
>>> it to.
>>>
>>> Clinton
>>>
>>> On Tue, Apr 6, 2010 at 9:09 PM, Viv Kapadekar <vivek@peoplepowerco.com
>>> > wrote:
>>> Yeah actually to make it more clear Class X also has desc. So its
>>> really:
>>> Class X {
>>> String id
>>> String desc
>>> List<Y> b
>>> }
>>> If index is null the desc is applicable for X and when its not
>>> null it should be applicable to X.
>>>
>>> --V
>>>
>>> On Apr 6, 2010, at 7:21 PM, Clinton Begin wrote:
>>>
>>>> If iBATIS finds ANY values for the mapped properties, it will
>>>> create the object. Is it possible that the desc column is
>>>> populated even when the index is null?
>>>>
>>>> On Tue, Apr 6, 2010 at 7:52 PM, Viv Kapadekar <vivek@peoplepowerco.com
>>>> > wrote:
>>>> Hi
>>>> I have a Class X containing a List of Class Y
>>>>
>>>> Class X {
>>>> String a
>>>> List<Y> b
>>>> }
>>>>
>>>> Class Y {
>>>> String index
>>>> String desc
>>>> }
>>>>
>>>> The resultMap I have is
>>>>
>>>> <resultMap id="someID" type="X">
>>>> <id property="a" column="id"/>
>>>> <collection property="b" ofType="Y">
>>>> <id property="index"
>>>> column="index" />
>>>> <result property="desc"
>>>> column="desc"/> -->
>>>> </collection>
>>>> </resultMap>
>>>>
>>>> This is fine, but I don't want the resulting X to have the
>>>> collection b set, if the "index" value is null. If index is null,
>>>> even the value of b in X should be null. I tried using
>>>> <discriminator> and also tried creating a separate sql, but no
>>>> luck. Any ideas?
>>>>
>>>> -V
>>>>
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
>>>> For additional commands, e-mail: user-java-help@ibatis.apache.org
>>>>
>>>>
>>>
>>> ---------------------------------------------------------------
>>> Viv Kapadekar
>>> vivek@peoplepowerco.com
>>>
>>>
>>
>> ---------------------------------------------------------------
>> Viv Kapadekar
>> vivek@peoplepowerco.com
>>
>
> ---------------------------------------------------------------
> Viv Kapadekar
> vivek@peoplepowerco.com
>
>
---------------------------------------------------------------
Viv Kapadekar
vivek@peoplepowerco.com
Re: [IBatis3-beta10] nested results for collection
Posted by Clinton Begin <cl...@gmail.com>.
Weird that an error was not thrown in that case... I'll have a look to see
why this condition would go ignored.
Thanks for tracking the defect down. If you get a chance, copy this message
into a Jira defect.
Clinton
On Wed, Apr 7, 2010 at 12:41 PM, Viv Kapadekar <vi...@peoplepowerco.com>wrote:
> Ah, found it. The column attribute was missing from Collection. Added that
> and it worked.
>
>
> <collection property="carParts" *column="id"* javaType="ArrayList"
> ofType="Parts" select="getCarPartInfo"/>
>
>
> 2010-04-07 11:38:47,254 DEBUG [iBatisImplTest] Car id 1 name Audi
> 2010-04-07 11:38:47,255 DEBUG [iBatisImplTest] car Part iterator is not
> null 3
> 2010-04-07 11:38:47,255 DEBUG [iBatisImplTest] Car Part index 100 Name
> door
> 2010-04-07 11:38:47,255 DEBUG [iBatisImplTest] Car Part index 101 Name
> windshield
> 2010-04-07 11:38:47,256 DEBUG [iBatisImplTest] Car Part index 102 Name
> Brakes
>
>
>
> Hi Clinton
>
> Basically what I am seeing is the nested select is not getting executed. To
> make it simpler, I created a simple prototype. I know in this example I
> don't need to create a separate select, but wondering why its not working.
> Here are the details
>
> *POJOs*
> public class Car
> {
> private int carId ;
> private String name ;
>
> private List<Parts> carParts ;
> }
>
>
> public class Parts
> {
> private int partId;
> private String name ;
> }
>
> *==============*
> *Mapper*
>
> <resultMap id="carResult" type="Car">
> <id property="carId" column="id"/>
> <result property="name" column="name"/>
> <collection property="carParts" javaType="ArrayList" ofType="Parts"
> select="getCarPartInfo"/>
> </resultMap>
>
> <select id="getCarsInfo" resultMap="carResult">
> SELECT car_id as "id", name
> FROM Car where car_id=1
> </select>
>
> <select id="getCarPartInfo" resultType="Parts">
> SELECT part_id as "partId", name
> FROM Parts where car_id=1
> </select>
> ==========
> Tables
> ======
>
>
> mysql> select * from car;
> +--------+------+
> | car_id | name |
> +--------+------+
> | 1 | Audi |
> +--------+------+
> 1 row in set (0.00 sec)
>
>
> mysql> select * from Parts;
> +---------+------------+--------+
> | part_id | name | car_id |
> +---------+------------+--------+
> | 100 | door | 1 |
> | 101 | windshield | 1 |
> | 102 | Brakes | 1 |
> +---------+------------+--------+
> 3 rows in set (0.00 sec)
>
>
> =========================
>
> *Unit Test*
> *
> *
> **
> *
> public void testGetCarInfo() {
> List<Car> list = repository.getCarsInfo();
> for (Iterator<Car> carIter = list.iterator();carIter.hasNext();) {
> Car d = carIter.next();
> logger.debug("Car id " + d.getCarId() + " name " + d.getName());
> List<Parts> dPartList = d.getCarParts();
> if (dPartList!=null) {
> logger.debug(" car Part iterator is not null " + dPartList.size());
> } else {
> logger.debug(" car Part List is null " );
> }
>
> }
> assertNotNull("At least one device must exist", list);
> }
> *
>
>
>
> Unit Test Result
>
> 2010-04-07 11:27:11,576 DEBUG [iBatisImplTest] Car id 1 name Audi
> 2010-04-07 11:27:11,577 DEBUG [iBatisImplTest] car Part List is null
>
>
> As you can see the result does not contain the Parts List, the Collection
> is not getting set. What is missing?
>
> -V
>
>
>
>
>
> On Apr 6, 2010, at 8:49 PM, Clinton Begin wrote:
>
> So you have desc in two places? This is getting more confusing. Maybe
> post the expected result set and the classes you're mapping it to.
>
> Clinton
>
> On Tue, Apr 6, 2010 at 9:09 PM, Viv Kapadekar <vi...@peoplepowerco.com>wrote:
>
>> Yeah actually to make it more clear Class X also has desc. So its really:
>> Class X {
>> String id
>> String desc
>> List<Y> b
>> }
>> If index is null the desc is applicable for X and when its not null it
>> should be applicable to X.
>>
>> --V
>>
>> On Apr 6, 2010, at 7:21 PM, Clinton Begin wrote:
>>
>> If iBATIS finds ANY values for the mapped properties, it will create the
>> object. Is it possible that the desc column is populated even when the
>> index is null?
>>
>> On Tue, Apr 6, 2010 at 7:52 PM, Viv Kapadekar <vi...@peoplepowerco.com>wrote:
>>
>>> Hi
>>> I have a Class X containing a List of Class Y
>>>
>>> Class X {
>>> String a
>>> List<Y> b
>>> }
>>>
>>> Class Y {
>>> String index
>>> String desc
>>> }
>>>
>>> The resultMap I have is
>>>
>>> <resultMap id="someID" type="X">
>>> <id property="a" column="id"/>
>>> <collection property="b" ofType="Y">
>>> <id property="index" column="index"
>>> />
>>> <result property="desc"
>>> column="desc"/> -->
>>> </collection>
>>> </resultMap>
>>>
>>> This is fine, but I don't want the resulting X to have the collection b
>>> set, if the "index" value is null. If index is null, even the value of b in
>>> X should be null. I tried using <discriminator> and also tried creating a
>>> separate sql, but no luck. Any ideas?
>>>
>>> -V
>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
>>> For additional commands, e-mail: user-java-help@ibatis.apache.org
>>>
>>>
>>
>> ---------------------------------------------------------------
>> Viv Kapadekar
>> vivek@peoplepowerco.com
>>
>>
>
> ---------------------------------------------------------------
> Viv Kapadekar
> vivek@peoplepowerco.com
>
>
> ---------------------------------------------------------------
> Viv Kapadekar
> vivek@peoplepowerco.com
>
>
Re: [IBatis3-beta10] nested results for collection
Posted by Viv Kapadekar <vi...@peoplepowerco.com>.
Ah, found it. The column attribute was missing from Collection. Added
that and it worked.
> <collection property="carParts" column="id" javaType="ArrayList"
> ofType="Parts" select="getCarPartInfo"/>
2010-04-07 11:38:47,254 DEBUG [iBatisImplTest] Car id 1 name Audi
2010-04-07 11:38:47,255 DEBUG [iBatisImplTest] car Part iterator is
not null 3
2010-04-07 11:38:47,255 DEBUG [iBatisImplTest] Car Part index 100
Name door
2010-04-07 11:38:47,255 DEBUG [iBatisImplTest] Car Part index 101
Name windshield
2010-04-07 11:38:47,256 DEBUG [iBatisImplTest] Car Part index 102
Name Brakes
> Hi Clinton
>
> Basically what I am seeing is the nested select is not getting
> executed. To make it simpler, I created a simple prototype. I know
> in this example I don't need to create a separate select, but
> wondering why its not working. Here are the details
>
> POJOs
> public class Car
> {
> private int carId ;
> private String name ;
>
> private List<Parts> carParts ;
> }
>
>
> public class Parts
> {
> private int partId;
> private String name ;
> }
>
> ==============
> Mapper
>
> <resultMap id="carResult" type="Car">
> <id property="carId" column="id"/>
> <result property="name" column="name"/>
> <collection property="carParts" javaType="ArrayList"
> ofType="Parts" select="getCarPartInfo"/>
> </resultMap>
>
> <select id="getCarsInfo" resultMap="carResult">
> SELECT car_id as "id", name
> FROM Car where car_id=1
> </select>
>
> <select id="getCarPartInfo" resultType="Parts">
> SELECT part_id as "partId", name
> FROM Parts where car_id=1
> </select>
> ==========
> Tables
> ======
>
>
> mysql> select * from car;
> +--------+------+
> | car_id | name |
> +--------+------+
> | 1 | Audi |
> +--------+------+
> 1 row in set (0.00 sec)
>
>
> mysql> select * from Parts;
> +---------+------------+--------+
> | part_id | name | car_id |
> +---------+------------+--------+
> | 100 | door | 1 |
> | 101 | windshield | 1 |
> | 102 | Brakes | 1 |
> +---------+------------+--------+
> 3 rows in set (0.00 sec)
>
>
> =========================
>
> Unit Test
>
> public void testGetCarInfo() {
> List<Car> list = repository.getCarsInfo();
> for (Iterator<Car> carIter = list.iterator();carIter.hasNext();) {
> Car d = carIter.next();
> logger.debug("Car id " + d.getCarId() + " name " + d.getName());
> List<Parts> dPartList = d.getCarParts();
> if (dPartList!=null) {
> logger.debug(" car Part iterator is not null " +
> dPartList.size());
> } else {
> logger.debug(" car Part List is null " );
> }
>
> }
>
> assertNotNull("At least one device must exist", list);
> }
>
>
>
> Unit Test Result
>
> 2010-04-07 11:27:11,576 DEBUG [iBatisImplTest] Car id 1 name Audi
> 2010-04-07 11:27:11,577 DEBUG [iBatisImplTest] car Part List is null
>
>
> As you can see the result does not contain the Parts List, the
> Collection is not getting set. What is missing?
>
> -V
>
>
>
>
>
> On Apr 6, 2010, at 8:49 PM, Clinton Begin wrote:
>
>> So you have desc in two places? This is getting more confusing.
>> Maybe post the expected result set and the classes you're mapping
>> it to.
>>
>> Clinton
>>
>> On Tue, Apr 6, 2010 at 9:09 PM, Viv Kapadekar <vivek@peoplepowerco.com
>> > wrote:
>> Yeah actually to make it more clear Class X also has desc. So its
>> really:
>> Class X {
>> String id
>> String desc
>> List<Y> b
>> }
>> If index is null the desc is applicable for X and when its not null
>> it should be applicable to X.
>>
>> --V
>>
>> On Apr 6, 2010, at 7:21 PM, Clinton Begin wrote:
>>
>>> If iBATIS finds ANY values for the mapped properties, it will
>>> create the object. Is it possible that the desc column is
>>> populated even when the index is null?
>>>
>>> On Tue, Apr 6, 2010 at 7:52 PM, Viv Kapadekar <vivek@peoplepowerco.com
>>> > wrote:
>>> Hi
>>> I have a Class X containing a List of Class Y
>>>
>>> Class X {
>>> String a
>>> List<Y> b
>>> }
>>>
>>> Class Y {
>>> String index
>>> String desc
>>> }
>>>
>>> The resultMap I have is
>>>
>>> <resultMap id="someID" type="X">
>>> <id property="a" column="id"/>
>>> <collection property="b" ofType="Y">
>>> <id property="index"
>>> column="index" />
>>> <result property="desc"
>>> column="desc"/> -->
>>> </collection>
>>> </resultMap>
>>>
>>> This is fine, but I don't want the resulting X to have the
>>> collection b set, if the "index" value is null. If index is null,
>>> even the value of b in X should be null. I tried using
>>> <discriminator> and also tried creating a separate sql, but no
>>> luck. Any ideas?
>>>
>>> -V
>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
>>> For additional commands, e-mail: user-java-help@ibatis.apache.org
>>>
>>>
>>
>> ---------------------------------------------------------------
>> Viv Kapadekar
>> vivek@peoplepowerco.com
>>
>>
>
> ---------------------------------------------------------------
> Viv Kapadekar
> vivek@peoplepowerco.com
>
---------------------------------------------------------------
Viv Kapadekar
vivek@peoplepowerco.com
Re: [IBatis3-beta10] nested results for collection
Posted by Viv Kapadekar <vi...@peoplepowerco.com>.
Hi Clinton
Basically what I am seeing is the nested select is not getting
executed. To make it simpler, I created a simple prototype. I know in
this example I don't need to create a separate select, but wondering
why its not working. Here are the details
POJOs
public class Car
{
private int carId ;
private String name ;
private List<Parts> carParts ;
}
public class Parts
{
private int partId;
private String name ;
}
==============
Mapper
<resultMap id="carResult" type="Car">
<id property="carId" column="id"/>
<result property="name" column="name"/>
<collection property="carParts" javaType="ArrayList" ofType="Parts"
select="getCarPartInfo"/>
</resultMap>
<select id="getCarsInfo" resultMap="carResult">
SELECT car_id as "id", name
FROM Car where car_id=1
</select>
<select id="getCarPartInfo" resultType="Parts">
SELECT part_id as "partId", name
FROM Parts where car_id=1
</select>
==========
Tables
======
mysql> select * from car;
+--------+------+
| car_id | name |
+--------+------+
| 1 | Audi |
+--------+------+
1 row in set (0.00 sec)
mysql> select * from Parts;
+---------+------------+--------+
| part_id | name | car_id |
+---------+------------+--------+
| 100 | door | 1 |
| 101 | windshield | 1 |
| 102 | Brakes | 1 |
+---------+------------+--------+
3 rows in set (0.00 sec)
=========================
Unit Test
public void testGetCarInfo() {
List<Car> list = repository.getCarsInfo();
for (Iterator<Car> carIter = list.iterator();carIter.hasNext();) {
Car d = carIter.next();
logger.debug("Car id " + d.getCarId() + " name " + d.getName());
List<Parts> dPartList = d.getCarParts();
if (dPartList!=null) {
logger.debug(" car Part iterator is not null " +
dPartList.size());
} else {
logger.debug(" car Part List is null " );
}
}
assertNotNull("At least one device must exist", list);
}
Unit Test Result
2010-04-07 11:27:11,576 DEBUG [iBatisImplTest] Car id 1 name Audi
2010-04-07 11:27:11,577 DEBUG [iBatisImplTest] car Part List is null
As you can see the result does not contain the Parts List, the
Collection is not getting set. What is missing?
-V
On Apr 6, 2010, at 8:49 PM, Clinton Begin wrote:
> So you have desc in two places? This is getting more confusing.
> Maybe post the expected result set and the classes you're mapping it
> to.
>
> Clinton
>
> On Tue, Apr 6, 2010 at 9:09 PM, Viv Kapadekar
> <vi...@peoplepowerco.com> wrote:
> Yeah actually to make it more clear Class X also has desc. So its
> really:
> Class X {
> String id
> String desc
> List<Y> b
> }
> If index is null the desc is applicable for X and when its not null
> it should be applicable to X.
>
> --V
>
> On Apr 6, 2010, at 7:21 PM, Clinton Begin wrote:
>
>> If iBATIS finds ANY values for the mapped properties, it will
>> create the object. Is it possible that the desc column is
>> populated even when the index is null?
>>
>> On Tue, Apr 6, 2010 at 7:52 PM, Viv Kapadekar <vivek@peoplepowerco.com
>> > wrote:
>> Hi
>> I have a Class X containing a List of Class Y
>>
>> Class X {
>> String a
>> List<Y> b
>> }
>>
>> Class Y {
>> String index
>> String desc
>> }
>>
>> The resultMap I have is
>>
>> <resultMap id="someID" type="X">
>> <id property="a" column="id"/>
>> <collection property="b" ofType="Y">
>> <id property="index"
>> column="index" />
>> <result property="desc"
>> column="desc"/> -->
>> </collection>
>> </resultMap>
>>
>> This is fine, but I don't want the resulting X to have the
>> collection b set, if the "index" value is null. If index is null,
>> even the value of b in X should be null. I tried using
>> <discriminator> and also tried creating a separate sql, but no
>> luck. Any ideas?
>>
>> -V
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
>> For additional commands, e-mail: user-java-help@ibatis.apache.org
>>
>>
>
> ---------------------------------------------------------------
> Viv Kapadekar
> vivek@peoplepowerco.com
>
>
---------------------------------------------------------------
Viv Kapadekar
vivek@peoplepowerco.com
Re: [IBatis3-beta10] nested results for collection
Posted by Clinton Begin <cl...@gmail.com>.
So you have desc in two places? This is getting more confusing. Maybe post
the expected result set and the classes you're mapping it to.
Clinton
On Tue, Apr 6, 2010 at 9:09 PM, Viv Kapadekar <vi...@peoplepowerco.com>wrote:
> Yeah actually to make it more clear Class X also has desc. So its really:
> Class X {
> String id
> String desc
> List<Y> b
> }
> If index is null the desc is applicable for X and when its not null it
> should be applicable to X.
>
> --V
>
> On Apr 6, 2010, at 7:21 PM, Clinton Begin wrote:
>
> If iBATIS finds ANY values for the mapped properties, it will create the
> object. Is it possible that the desc column is populated even when the
> index is null?
>
> On Tue, Apr 6, 2010 at 7:52 PM, Viv Kapadekar <vi...@peoplepowerco.com>wrote:
>
>> Hi
>> I have a Class X containing a List of Class Y
>>
>> Class X {
>> String a
>> List<Y> b
>> }
>>
>> Class Y {
>> String index
>> String desc
>> }
>>
>> The resultMap I have is
>>
>> <resultMap id="someID" type="X">
>> <id property="a" column="id"/>
>> <collection property="b" ofType="Y">
>> <id property="index" column="index"
>> />
>> <result property="desc"
>> column="desc"/> -->
>> </collection>
>> </resultMap>
>>
>> This is fine, but I don't want the resulting X to have the collection b
>> set, if the "index" value is null. If index is null, even the value of b in
>> X should be null. I tried using <discriminator> and also tried creating a
>> separate sql, but no luck. Any ideas?
>>
>> -V
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
>> For additional commands, e-mail: user-java-help@ibatis.apache.org
>>
>>
>
> ---------------------------------------------------------------
> Viv Kapadekar
> vivek@peoplepowerco.com
>
>
Re: [IBatis3-beta10] nested results for collection
Posted by Viv Kapadekar <vi...@peoplepowerco.com>.
Yeah actually to make it more clear Class X also has desc. So its
really:
Class X {
String id
String desc
List<Y> b
}
If index is null the desc is applicable for X and when its not null it
should be applicable to X.
--V
On Apr 6, 2010, at 7:21 PM, Clinton Begin wrote:
> If iBATIS finds ANY values for the mapped properties, it will create
> the object. Is it possible that the desc column is populated even
> when the index is null?
>
> On Tue, Apr 6, 2010 at 7:52 PM, Viv Kapadekar
> <vi...@peoplepowerco.com> wrote:
> Hi
> I have a Class X containing a List of Class Y
>
> Class X {
> String a
> List<Y> b
> }
>
> Class Y {
> String index
> String desc
> }
>
> The resultMap I have is
>
> <resultMap id="someID" type="X">
> <id property="a" column="id"/>
> <collection property="b" ofType="Y">
> <id property="index"
> column="index" />
> <result property="desc"
> column="desc"/> -->
> </collection>
> </resultMap>
>
> This is fine, but I don't want the resulting X to have the
> collection b set, if the "index" value is null. If index is null,
> even the value of b in X should be null. I tried using
> <discriminator> and also tried creating a separate sql, but no luck.
> Any ideas?
>
> -V
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
> For additional commands, e-mail: user-java-help@ibatis.apache.org
>
>
---------------------------------------------------------------
Viv Kapadekar
vivek@peoplepowerco.com
Re: [IBatis3-beta10] nested results for collection
Posted by Clinton Begin <cl...@gmail.com>.
If iBATIS finds ANY values for the mapped properties, it will create the
object. Is it possible that the desc column is populated even when the
index is null?
On Tue, Apr 6, 2010 at 7:52 PM, Viv Kapadekar <vi...@peoplepowerco.com>wrote:
> Hi
> I have a Class X containing a List of Class Y
>
> Class X {
> String a
> List<Y> b
> }
>
> Class Y {
> String index
> String desc
> }
>
> The resultMap I have is
>
> <resultMap id="someID" type="X">
> <id property="a" column="id"/>
> <collection property="b" ofType="Y">
> <id property="index" column="index" />
> <result property="desc"
> column="desc"/> -->
> </collection>
> </resultMap>
>
> This is fine, but I don't want the resulting X to have the collection b
> set, if the "index" value is null. If index is null, even the value of b in
> X should be null. I tried using <discriminator> and also tried creating a
> separate sql, but no luck. Any ideas?
>
> -V
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
> For additional commands, e-mail: user-java-help@ibatis.apache.org
>
>
[IBatis3-beta10] nested results for collection
Posted by Viv Kapadekar <vi...@peoplepowerco.com>.
Hi
I have a Class X containing a List of Class Y
Class X {
String a
List<Y> b
}
Class Y {
String index
String desc
}
The resultMap I have is
<resultMap id="someID" type="X">
<id property="a" column="id"/>
<collection property="b" ofType="Y">
<id property="index"
column="index" />
<result property="desc" column="desc"/> -->
</collection>
</resultMap>
This is fine, but I don't want the resulting X to have the collection
b set, if the "index" value is null. If index is null, even the value
of b in X should be null. I tried using <discriminator> and also
tried creating a separate sql, but no luck. Any ideas?
-V
---------------------------------------------------------------------
To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
For additional commands, e-mail: user-java-help@ibatis.apache.org
Re: Eclipse Plugin for iBatis 3.0- beta 10?
Posted by Guy Rouillier <gu...@burntmail.com>.
On 4/6/2010 6:18 PM, Viv Kapadekar wrote:
> Hi All
>
> Is there a Eclipse plugin for iBatis 3.0-beta 10 (or the latest) ?
Which plugin are you looking for? Eclibatis or Ibator? The former can
be installed from here:
http://sourceforge.net/projects/eclibatis/develop. The latter hasn't
been released yet, so to get a version that is iBATIS 3 compatible,
you'll need to build it from source.
--
Guy Rouillier
---------------------------------------------------------------------
To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
For additional commands, e-mail: user-java-help@ibatis.apache.org
Eclipse Plugin for iBatis 3.0- beta 10?
Posted by Viv Kapadekar <vi...@peoplepowerco.com>.
Hi All
Is there a Eclipse plugin for iBatis 3.0-beta 10 (or the latest) ?
--Viv
---------------------------------------------------------------------
To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
For additional commands, e-mail: user-java-help@ibatis.apache.org
Re: SqlSession.close() without committing
Posted by Clinton Begin <cl...@gmail.com>.
Yes, iBATIS will rollback the connection if it deems it necessary. The only
time you might need to call rollback explicitly is if you have a "select"
that actually updates data in the database. Such is sometimes the case with
stored procedures.
Clinton
2010/4/5 François Schiettecatte <fs...@gmail.com>
> If you start a transaction or don't have auto-commit on, then the
> transaction will be rolled back. At least that is what I am seeing which
> makes sense to me.
>
> F.
>
> On Apr 5, 2010, at 12:38 PM, cowwoc wrote:
>
> > Hi,
> >
> > What happens if I close() a SqlSession without committing? Does iBatis
> guarantee that the transaction will roll back? I ask because I want to use
> the following pattern:
> >
> > SqlSession session = factory.openSession();
> > try
> > {
> > // do work
> > session.commit();
> > }
> > finally
> > {
> > session.close();
> > }
> >
> > If no exception is thrown, the session gets committed. Otherwise, it
> is rolled back without having to catch exceptions and explicitly roll back.
> >
> > Thanks,
> > Gili
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
> > For additional commands, e-mail: user-java-help@ibatis.apache.org
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
> For additional commands, e-mail: user-java-help@ibatis.apache.org
>
>
Re: SqlSession.close() without committing
Posted by François Schiettecatte <fs...@gmail.com>.
If you start a transaction or don't have auto-commit on, then the transaction will be rolled back. At least that is what I am seeing which makes sense to me.
F.
On Apr 5, 2010, at 12:38 PM, cowwoc wrote:
> Hi,
>
> What happens if I close() a SqlSession without committing? Does iBatis guarantee that the transaction will roll back? I ask because I want to use the following pattern:
>
> SqlSession session = factory.openSession();
> try
> {
> // do work
> session.commit();
> }
> finally
> {
> session.close();
> }
>
> If no exception is thrown, the session gets committed. Otherwise, it is rolled back without having to catch exceptions and explicitly roll back.
>
> Thanks,
> Gili
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
> For additional commands, e-mail: user-java-help@ibatis.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
For additional commands, e-mail: user-java-help@ibatis.apache.org