deepakl_2000 | 2 Dec 2009 18:30
Picon
Favicon

Issue with join of 2 tables in Ibatis


Hi,

    I have to fetch a list from 2 tables based on below condition.

[code]

-------------------

Service class

-------------------

fileParameters.put("Project_Code",projectCode);

fileParameters.put("Files_ID",filePk);

responseFileData =
(List)sqlMap.queryForList("getFileResponses",fileParameters);

-------------------------------------------------------
query.xml

<parameterMap id="FileDetails" class="java.util.Map" >                                               
                <parameter property="Project_Code" jdbcType="VARCHAR" />
                <parameter property="Files_ID" jdbcType="INT" />
</parameterMap>

<resultMap id="get_list" class="com.hcl.fpTool.pojo.ResponseFilesDataPOJO">
            <result property="rule_Id" column="Rule_Id"/>           
(Continue reading)

Jason H King | 2 Dec 2009 19:08

Re: Issue with join of 2 tables in Ibatis

Your query gets the 4 columns you need from the appropriate tables.
You just need to change your resultmap and ResponseFilesDataPOJO to have all 4 values.

class ResponseFilesDataPOJO{
    private String rule_id;
    private String response;
    private String remarks;
    private String rule_desc;   
// constructor , getters , setters
}
<resultMap id="get_list" class="com.hcl.fpTool.pojo.ResponseFilesDataPOJO">
            <result property="rule_Id" column="Rule_Id"/>           
            <result property="response" column="Response"/>                        
            <result property="remarks" column="Remarks"/>                        
            <result property="rule_desc" column="Rule_desc"/>
/resultMap>

--- deepakl_2000 <at> yahoo.com wrote:

From: deepakl_2000 <deepakl_2000 <at> yahoo.com>
To: dev <at> ibatis.apache.org
Subject: Issue with join of 2 tables in Ibatis
Date: Wed, 2 Dec 2009 09:30:06 -0800 (PST)

Hi,

    I have to fetch a list from 2 tables based on below condition.

[code]

(Continue reading)

deepakl_2000 | 3 Dec 2009 07:13
Picon
Favicon

Re: Issue with join of 2 tables in Ibatis


Hi jhking,
           Im sorry to say that "rule_desc" is not a property of
ResponseFilesDataPOJO.it is a property of some other class,please dont get
confused...

1> bstatic.rule_desc is coming from  another table "BusinessRule_StaticData
bstatic"
2> bres.rule_id,bres.remarks,bres.response is coming from another table "
BusinessRule_ResFiles_Data bres"

Then i perform a join as shown below.

            select bres.rule_id,
bstatic.rule_desc,bres.remarks,bres.response 
            from BusinessRule_ResFiles_Data bres, BusinessRule_StaticData
bstatic
            where  project_Code = ? and files_id = ?
            and bres.rule_id = bstatic.rule_id and bres.rule_id not like
('%CD%')   

public class StaticDataPOJO {
	private String rule_Desc;
            //getters and setters
}

class ResponseFilesDataPOJO{
    private String rule_id;
    private String response;
    private String remarks;
(Continue reading)

Jason King | 3 Dec 2009 07:21

Re: Issue with join of 2 tables in Ibatis

Yes, someone in this discussion is confused...
I said to change the ResponseFilesDataPOJO class to have that attribute.
You can't have a single select populate 2 resultmaps so if you want the extra column(s) you'll need them in the class.
If, for some reason, you can't change ResponseFilesDataPOJO then you'll need another class with all the column values you want back or write two queries (and have a 2nd class to get the results of the 2nd query).
It would seem add a new property to the existing class would be easiest all around.
deepakl_2000 wrote:
Hi jhking, Im sorry to say that "rule_desc" is not a property of ResponseFilesDataPOJO.it is a property of some other class,please dont get confused... 1> bstatic.rule_desc is coming from another table "BusinessRule_StaticData bstatic" 2> bres.rule_id,bres.remarks,bres.response is coming from another table " BusinessRule_ResFiles_Data bres" Then i perform a join as shown below. select bres.rule_id, bstatic.rule_desc,bres.remarks,bres.response from BusinessRule_ResFiles_Data bres, BusinessRule_StaticData bstatic where project_Code = ? and files_id = ? and bres.rule_id = bstatic.rule_id and bres.rule_id not like ('%CD%') public class StaticDataPOJO { private String rule_Desc; //getters and setters } class ResponseFilesDataPOJO{ private String rule_id; private String response; private String remarks; // constructor , getters , setters } please help me now..... how should i change my query.xml file to get the correct fetch.....could you please modify my code below and let me know how to proceed ------------------------------------------------------- query.xml <parameterMap id="FileDetails" class="java.util.Map" > <parameter property="Project_Code" jdbcType="VARCHAR" /> <parameter property="Files_ID" jdbcType="INT" /> </parameterMap> <resultMap id="get_list" class="com.hcl.fpTool.pojo.ResponseFilesDataPOJO"> <result property="rule_Id" column="Rule_Id"/> <result property="response" column="Response"/> <result property="remarks" column="Remarks"/> /resultMap> <select id="getFileResponses" resultClass="com.hcl.fpTool.pojo.ResponseFilesDataPOJO" parameterMap="FileDetails" resultMap="get_list"> select bres.rule_id, bstatic.rule_desc,bres.remarks, bres.response from BusinessRule_ResFiles_Data bres, BusinessRule_StaticData bstatic where project_Code = ? and files_id = ? and bres.rule_id = bstatic.rule_id and bres.rule_id not like ('%CD%') </select> Please need help forum people..im stuck with this for quite a while some time.... i will be highly thankful to you guys if could help me with this..... Thanks in advance for your quick replies... :confused: jhking wrote:
Your query gets the 4 columns you need from the appropriate tables. You just need to change your resultmap and ResponseFilesDataPOJO to have all 4 values. class ResponseFilesDataPOJO{ private String rule_id; private String response; private String remarks; private String rule_desc; // constructor , getters , setters } <resultMap id="get_list" class="com.hcl.fpTool.pojo.ResponseFilesDataPOJO"> <result property="rule_Id" column="Rule_Id"/> <result property="response" column="Response"/> <result property="remarks" column="Remarks"/> <result property="rule_desc" column="Rule_desc"/> /resultMap> --- deepakl_2000 <at> yahoo.com wrote: From: deepakl_2000 <deepakl_2000 <at> yahoo.com> To: dev <at> ibatis.apache.org Subject: Issue with join of 2 tables in Ibatis Date: Wed, 2 Dec 2009 09:30:06 -0800 (PST) Hi, I have to fetch a list from 2 tables based on below condition. [code] ------------------- Service class ------------------- fileParameters.put("Project_Code",projectCode); fileParameters.put("Files_ID",filePk); responseFileData = (List)sqlMap.queryForList("getFileResponses",fileParameters); ------------------------------------------------------- query.xml <parameterMap id="FileDetails" class="java.util.Map" > <parameter property="Project_Code" jdbcType="VARCHAR" /> <parameter property="Files_ID" jdbcType="INT" /> </parameterMap> <resultMap id="get_list" class="com.hcl.fpTool.pojo.ResponseFilesDataPOJO"> <result property="rule_Id" column="Rule_Id"/> <result property="response" column="Response"/> <result property="remarks" column="Remarks"/> /resultMap> <select id="getFileResponses" resultClass="com.hcl.fpTool.pojo.ResponseFilesDataPOJO" parameterMap="FileDetails" resultMap="get_list"> select bres.rule_id, bstatic.rule_desc,bres.remarks, bres.response from BusinessRule_ResFiles_Data bres, BusinessRule_StaticData bstatic where project_Code = ? and files_id = ? and bres.rule_id = bstatic.rule_id and bres.rule_id not like ('%CD%') </select> The problem lies here is 1> i need to select "bstatic.rule_desc" from my another table "BusinessRule_StaticData" 2>i need to select "bres.rule_id" from my another table "BusinessRule_ResFiles_Data" so i have a total select of 4 columns based on a join of 2 tables. so please help me to correct the "query.xml" file such that i can accomplish the selection of 4 columns and retrieve it back as a list in my service class -- View this message in context: http://old.nabble.com/Issue-with-join-of-2-tables-in-Ibatis-tp26612861p26612861.html Sent from the iBATIS - Dev mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe <at> ibatis.apache.org For additional commands, e-mail: dev-help <at> ibatis.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe <at> ibatis.apache.org For additional commands, e-mail: dev-help <at> ibatis.apache.org

crmanoj | 10 Dec 2009 13:37
Picon

Search for character '_', '%' wildcard characters using ibatis


Hi,

I am new to iBatis. I'm using iBatis with Oracle. My Database entries have
values with wild card characters like '_' or '%'. My application demands to
retrieve all the entries with the character '_'. For Searching such
characters i can use escape character( ESCAPE '\') in oracle whereas i'm not
able to use the same thing in iBatis. How should my query be? Please help
with this.

Thanks in Advance.
-dk- | 10 Dec 2009 17:07
Picon

1st level cache control


Hi All,
Sorry, if anybody got this twice, I just decided that iBatis - Dev is better
place for my question.

I confused when couldn't find any control over the 1st-level cache which is
always On for select mapper.
What I found (thanks to open source) that easy way to do clean the cache is
to call session.commit() (or rollback).

I use scenario when session stays open for some time and I need to monitor
some value returned by select mapper.
This value is changed by other party, so all I need - just dirty read
periodically. Not wasting time on session opening and closing.
So it appears that there is no "dirty ops" approach and I have to call
commit/rollback between subsequent select in order to get updated value from
the db.

Was this initial intention or just oversighted?

Would be nice to have something way to turn cache off or to clean it on
demand. Using commit/rollback even in read-only context seems to be not
smart solution.

Thank you!

Clinton Begin | 10 Dec 2009 21:44
Picon

Re: 1st level cache control

It's not an oversight, and is definitely by design. 

It's built on the premise that it's a very bad idea to keep sessions open for any length of time. 

Cheers,
Clinton

On Thu, Dec 10, 2009 at 9:07 AM, -dk- <dmitriy.kargapolov <at> gmail.com> wrote:

Hi All,
Sorry, if anybody got this twice, I just decided that iBatis - Dev is better
place for my question.

I confused when couldn't find any control over the 1st-level cache which is
always On for select mapper.
What I found (thanks to open source) that easy way to do clean the cache is
to call session.commit() (or rollback).

I use scenario when session stays open for some time and I need to monitor
some value returned by select mapper.
This value is changed by other party, so all I need - just dirty read
periodically. Not wasting time on session opening and closing.
So it appears that there is no "dirty ops" approach and I have to call
commit/rollback between subsequent select in order to get updated value from
the db.

Was this initial intention or just oversighted?

Would be nice to have something way to turn cache off or to clean it on
demand. Using commit/rollback even in read-only context seems to be not
smart solution.

Thank you!

--
View this message in context: http://old.nabble.com/1st-level-cache-control-tp26729953p26729953.html
Sent from the iBATIS - Dev mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe <at> ibatis.apache.org
For additional commands, e-mail: dev-help <at> ibatis.apache.org


stefcl | 14 Dec 2009 10:33
Picon

Small error in v3 manual : conditional "&&" is not allowed


Hello,

Just to report that the following example in the manual :

<if test=”author != null && author.name != null”>

doesn't work because character "&" has a special meaning in XML.

Correct form should be something like 
<if test="author != null &amp;&amp; author.name != null">

which is less readable :-(. would be great if we had operators like "AND" or
"_AND_" instead which are more XML friendly.

Kind regards 
--

-- 
View this message in context: http://old.nabble.com/Small-error-in-v3-manual-%3A-conditional-%22--%22-is-not-allowed-tp26775069p26775069.html
Sent from the iBATIS - Dev mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe <at> ibatis.apache.org
For additional commands, e-mail: dev-help <at> ibatis.apache.org

stefcl | 14 Dec 2009 11:27
Picon

Re: Small error in v3 manual : conditional "&&" is not allowed


Please note that my corrected form doesn't show correctly on Nabble because
HTML entities are not properly escaped. Actually "&&" is "& amp ; & amp ;"
without spaces
Clinton Begin | 14 Dec 2009 16:01
Picon

Re: Small error in v3 manual : conditional "&&" is not allowed

Good news... you can use "and".  OGNL seems to support 'and' and 'or'.  I'll update the manual to avoid the crap syntax.  :-)



Cheers,
Clinton

On Mon, Dec 14, 2009 at 3:27 AM, stefcl <stefatwork <at> gmail.com> wrote:

Please note that my corrected form doesn't show correctly on Nabble because
HTML entities are not properly escaped. Actually "&&" is "& amp ; & amp ;"
without spaces
--
View this message in context: http://old.nabble.com/Small-error-in-v3-manual-%3A-conditional-%22--%22-is-not-allowed-tp26775069p26775691.html
Sent from the iBATIS - Dev mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe <at> ibatis.apache.org
For additional commands, e-mail: dev-help <at> ibatis.apache.org



Gmane