Odelya Glick | 2 Nov 01:33 2007

Caching problem using IBATIS

Hi,

I am trying to implement cache in IBATIS.

I declared the following statement:

<select id="getObituaryById" resultClass="obituary"
		parameterClass="string" cacheModel="obituaryCache">
		select ID as id,
		FIRST_NAME as firstName, MID_NAME as midName, SUR_NAME as
		surName, BIRTH_DATE as birthDate, PASS_DATE as passDate,
BODY as
		body, PHOTO_LINK as photoLink, THUMB_PHOTO_LINK as
		thumbPhotoLink FROM OBITUARY where ID =
		#value#
	</select>

And the cacheModel:
<cacheModel id="obituaryCache" type="LRU">
		<flushInterval hours="24" />
		<property name="cache-size" value="1000" />
		<flushOnExecute statement="insertObituary" />
	</cacheModel>

But it doesn't seem to be that the obituary object is being cached!
When I change a value in Oracle 9i, and do refresh to the page, I get the
newly updated information!

The code to get the information is:

(Continue reading)

Niels Beekman | 1 Nov 13:37 2007
Picon

RE: Caching problem using IBATIS

Did you enable caching globally in the config file?

Niels

-----Original Message-----
From: Odelya Glick [mailto:odelya <at> jpost.com] 
Sent: vrijdag 2 november 2007 1:33
To: user-java <at> ibatis.apache.org
Subject: Caching problem using IBATIS

Hi,

I am trying to implement cache in IBATIS.

I declared the following statement:

<select id="getObituaryById" resultClass="obituary"
		parameterClass="string" cacheModel="obituaryCache">
		select ID as id,
		FIRST_NAME as firstName, MID_NAME as midName, SUR_NAME
as
		surName, BIRTH_DATE as birthDate, PASS_DATE as passDate,
BODY as
		body, PHOTO_LINK as photoLink, THUMB_PHOTO_LINK as
		thumbPhotoLink FROM OBITUARY where ID =
		#value#
	</select>

And the cacheModel:
<cacheModel id="obituaryCache" type="LRU">
(Continue reading)

Odelya Glick | 2 Nov 01:54 2007

RE: Caching problem using IBATIS

I thought it's default to be true..

I set it now and it works perfect. 

Thanks

-----Original Message-----
From: Niels Beekman [mailto:n.beekman <at> wis.nl] 
Sent: Thursday, November 01, 2007 2:37 PM
To: user-java <at> ibatis.apache.org
Subject: RE: Caching problem using IBATIS

Did you enable caching globally in the config file?

Niels

-----Original Message-----
From: Odelya Glick [mailto:odelya <at> jpost.com] 
Sent: vrijdag 2 november 2007 1:33
To: user-java <at> ibatis.apache.org
Subject: Caching problem using IBATIS

Hi,

I am trying to implement cache in IBATIS.

I declared the following statement:

<select id="getObituaryById" resultClass="obituary"
		parameterClass="string" cacheModel="obituaryCache">
(Continue reading)

Odelya Glick | 2 Nov 03:20 2007

Problem with insertKey


Hi,

I am trying to receive primary key with:
<insert id="insertCondolence" parameterClass="condolence">
		<selectKey keyProperty="id" resultClass="int">
			SELECT obituary_seq.NEXTVAL AS value FROM dual
		</selectKey>
		INSERT INTO CONDOLENCE(ID, STATUS)
		VALUES(#id#,#status#)
	</insert>

The condolence class has 2 properties:
String id;
String status;

But it always inserts a record with the right status value, but id value is
always null!!

Why? 

Thanks
Odelya
web-programmer
050-2052075

Jean-Francois Poilpret | 1 Nov 15:40 2007
Picon

RE: Problem with insertKey

An Oracle sequence cannot map to a String, so your condolence class should
have the following properties:
int id; (or long)
String status;

Cheers

Jean-Francois

-----Original Message-----
From: Odelya Glick [mailto:odelya <at> jpost.com] 
Sent: Friday, November 02, 2007 9:21 AM
To: user-java <at> ibatis.apache.org
Subject: Problem with insertKey 

Hi,

I am trying to receive primary key with:
<insert id="insertCondolence" parameterClass="condolence">
		<selectKey keyProperty="id" resultClass="int">
			SELECT obituary_seq.NEXTVAL AS value FROM dual
		</selectKey>
		INSERT INTO CONDOLENCE(ID, STATUS)
		VALUES(#id#,#status#)
	</insert>

The condolence class has 2 properties:
String id;
String status;

(Continue reading)

Härtel, Eric | 1 Nov 16:14 2007
Picon

getting auto-generated key

Hello list,

I have "Person" class with several phone numbers (0-*) I have the numbers in a separate table with two
columns, persId and number. When I insert the person I want to insert the phone numbers, too. So I wrote:

<insert id="insertPerson" parameterClass="Person">
	INSERT INTO Person ( salutation, degree, firstname, ) 
		VALUES ( #salutation:VARCHAR#, #degree:VARCHAR#, #firstname:VARCHAR# );
	<selectKey resultClass="int" >
		SELECT  <at>  <at> IDENTITY AS ID
	</selectKey>
	<iterate property="telefonNrs" conjunction="; ">
		INSERT INTO phoneNumbers (persId, number)
		VALUES ( id, #telefonNrs[]# )
	</iterate>
</insert>

The problem is: I need the auto-generated person key to insert the phone numbers. How can I get?

Greetings Eric

Odelya Glick | 2 Nov 04:48 2007

RE: Problem with insertKey

Well,

I changed it, but it always puts value 0.

The sequence is declared like this:

CREATE SEQUENCE obituary_seq
    INCREMENT BY 3
    START WITH 100
    NOMAXVALUE
    MINVALUE 100
    NOCYCLE
    CACHE 20
    NOORDER

What could be the problem?

Many thanks,

Odelya

-----Original Message-----
From: Jean-Francois Poilpret [mailto:jfpoilpret <at> yahoo.fr] 
Sent: Thursday, November 01, 2007 4:40 PM
To: user-java <at> ibatis.apache.org
Subject: RE: Problem with insertKey 

An Oracle sequence cannot map to a String, so your condolence class should
have the following properties:
int id; (or long)
(Continue reading)

Thorsten Elfert | 1 Nov 17:11 2007

Error setting property in case of a null value - How to map correctly ?


Hi,

I am new on iBatis and I try to map an Oracle 9i based result and get the following error:

Caused by: java.lang.RuntimeException: Error setting property 'setRepurchaseFeeId' of XYZ ( XYZ <at> 913842e2    repurchaseFeeId = 0    targetGroupId = 0    offerFeeId = 0    offerId = null    transferToDo = FALSE    salesInfoId = 0    minimumQuota = 0    validFrom = null    quotaIsPublic = FALSE    ovwAdditionalInfo = null     )'.  Cause: java.lang.IllegalArgumentException
        at com.ibatis.sqlmap.engine.accessplan.PropertyAccessPlan.setProperties(PropertyAccessPlan.java:52)
        at com.ibatis.sqlmap.engine.exchange.JavaBeanDataExchange.setData(JavaBeanDataExchange.java:115)
        at com.ibatis.sqlmap.engine.mapping.result.BasicResultMap.setResultObjectValues(BasicResultMap.java:373)
        at com.ibatis.sqlmap.engine.mapping.statement.RowHandlerCallback.handleResultObject(RowHandlerCallback.java:64)
        at com.ibatis.sqlmap.engine.execution.SqlExecutor.handleResults(SqlExecutor.java:376)
        at com.ibatis.sqlmap.engine.execution.SqlExecutor.handleMultipleResults(SqlExecutor.java:295)
        at com.ibatis.sqlmap.engine.execution.SqlExecutor.executeQuery(SqlExecutor.java:186)
        at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.sqlExecuteQuery(GeneralStatement.java:205)
        at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryWithCallback(GeneralStatement.java:173)
        ... 38 more
Caused by: java.lang.IllegalArgumentException
        at com.ibatis.sqlmap.engine.accessplan.PropertyAccessPlan.setProperties(PropertyAccessPlan.java:46)

It is based on the following select…

<select id="getXYZ"
        resultClass="XYZ"
        parameterClass="int" resultMap="xyz-result">
        <![CDATA[
                select * from XYZ
                where id = #id#
        ]]>
</select>

..and the following result map definition:

<resultMap class="XYZ"
        id="xyz-result">
        <result property="repurchaseFeeId" column="REPURCHASE_FEE_ID" />
        <result property="pretaxYieldCalculation"
                column="PRETAX_YIELD_CALCULATION" />

</resultMap>


…an XML gets succesfully generated via:

<select id="getSecurityOfferInfoByIdAsXml" resultClass="xml"
        parameterClass="int" xmlResultName="securityOfferInfo-dummy">

        <![CDATA[
                select * from XYZ
                where id = #id#
        ]]>
</select>

Here is the result:

<?xml version="1.0" encoding="UTF-8"?>
<xzy>
        <SECURITY_ID>88888888</SECURITY_ID>
        <TARGET_GROUP_ID>1</TARGET_GROUP_ID>
        <OFFER_ID>O1</OFFER_ID>
        <REPURCHASE_ID>R9</REPURCHASE_ID>
        <TRANSFER_TO_DO>FALSE</TRANSFER_TO_DO>
        <QUOTA_IS_PUBLIC>FALSE</QUOTA_IS_PUBLIC>
        <USE_GENERATED_TEXT>FALSE</USE_GENERATED_TEXT>
        <YIELD_CALCULATION>FALSE</YIELD_CALCULATION>
        <PRETAX_YIELD_CALCULATION>FALSE</PRETAX_YIELD_CALCULATION>
        <VALID_FROM>2007-11-01 11:06:23.0</VALID_FROM>
</xyz>

All the null values are not part of the xml. As expected!

However, the java class cannot be instantiated (as you can see in the exception above)

For testing purposes I changed the entries in the result map like that:

        <result property="repurchaseFeeId" column="REPURCHASE_FEE_ID" nullValue=”0”/>


This works! But this workaround is not acceptable. I do not want to get some value instantiated if it is null in the corresponding database attribute.
The property should simply not being set!

Could somebody help me on that?


Thanks in advance!!
--

Informationen (einschließlich Pflichtangaben) zu einzelnen, innerhalb der EU tätigen Gesellschaften und Zweigniederlassungen des Konzerns Deutsche Bank finden Sie unter http://www.db.com/de/content/pflichtangaben.htm. Diese E-Mail enthält vertrauliche und/ oder rechtlich geschützte Informationen. Wenn Sie nicht der richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren Sie bitte sofort den Absender und vernichten Sie diese E-Mail. Das unerlaubte Kopieren sowie die unbefugte Weitergabe dieser E-Mail ist nicht gestattet.

Please refer to http://www.db.com/en/content/eu_disclosures.htm for information (including mandatory corporate particulars) on selected Deutsche Bank branches and group companies registered or incorporated in the European Union. This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and delete this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden.
Larry Meadors | 1 Nov 17:35 2007
Picon

Re: Caching problem using IBATIS

In your sqlMapConfig, look at the settings element, do you have
cacheModelsEnabled="true" there?

Larry

On 11/1/07, Odelya Glick <odelya <at> jpost.com> wrote:
> Hi,
>
> I am trying to implement cache in IBATIS.
>
> I declared the following statement:
>
> <select id="getObituaryById" resultClass="obituary"
>                 parameterClass="string" cacheModel="obituaryCache">
>                 select ID as id,
>                 FIRST_NAME as firstName, MID_NAME as midName, SUR_NAME as
>                 surName, BIRTH_DATE as birthDate, PASS_DATE as passDate,
> BODY as
>                 body, PHOTO_LINK as photoLink, THUMB_PHOTO_LINK as
>                 thumbPhotoLink FROM OBITUARY where ID =
>                 #value#
>         </select>
>
> And the cacheModel:
> <cacheModel id="obituaryCache" type="LRU">
>                 <flushInterval hours="24" />
>                 <property name="cache-size" value="1000" />
>                 <flushOnExecute statement="insertObituary" />
>         </cacheModel>
>
> But it doesn't seem to be that the obituary object is being cached!
> When I change a value in Oracle 9i, and do refresh to the page, I get the
> newly updated information!
>
> The code to get the information is:
>
> public ObituaryData getObituaryById(String obitId) {
>                   return  (ObituaryData) queryForObject("getObituaryById",
> obitId);
>         }
>
>
> Thanks
>
> Odelya
> web-programmer
>
>
>

Larry Meadors | 1 Nov 17:37 2007
Picon

Re: Problem with insertKey

Try

SELECT obituary_seq.NEXTVAL AS id FROM dual

instead (id, not value).

Larry

On 11/1/07, Odelya Glick <odelya <at> jpost.com> wrote:
> Well,
>
> I changed it, but it always puts value 0.
>
> The sequence is declared like this:
>
> CREATE SEQUENCE obituary_seq
>     INCREMENT BY 3
>     START WITH 100
>     NOMAXVALUE
>     MINVALUE 100
>     NOCYCLE
>     CACHE 20
>     NOORDER
>
> What could be the problem?
>
> Many thanks,
>
> Odelya
>
>
> -----Original Message-----
> From: Jean-Francois Poilpret [mailto:jfpoilpret <at> yahoo.fr]
> Sent: Thursday, November 01, 2007 4:40 PM
> To: user-java <at> ibatis.apache.org
> Subject: RE: Problem with insertKey
>
> An Oracle sequence cannot map to a String, so your condolence class should
> have the following properties:
> int id; (or long)
> String status;
>
> Cheers
>
> Jean-Francois
>
> -----Original Message-----
> From: Odelya Glick [mailto:odelya <at> jpost.com]
> Sent: Friday, November 02, 2007 9:21 AM
> To: user-java <at> ibatis.apache.org
> Subject: Problem with insertKey
>
>
> Hi,
>
> I am trying to receive primary key with:
> <insert id="insertCondolence" parameterClass="condolence">
>                 <selectKey keyProperty="id" resultClass="int">
>                         SELECT obituary_seq.NEXTVAL AS value FROM dual
>                 </selectKey>
>                 INSERT INTO CONDOLENCE(ID, STATUS)
>                 VALUES(#id#,#status#)
>         </insert>
>
> The condolence class has 2 properties:
> String id;
> String status;
>
> But it always inserts a record with the right status value, but id value is
> always null!!
>
> Why?
>
> Thanks
> Odelya
> web-programmer
> 050-2052075
>
>
>
>
>
>
>
>
> ****************************************************************************
> ********
> This footnote confirms that this email message has been scanned by
> PineApp Mail-SeCure for the presence of malicious code, vandals & computer
> viruses.
> ****************************************************************************
> ********
>
>
>
>
>


Gmane