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 Dodo <j2...@gmail.com> on 2006/06/15 03:47:57 UTC

database identity (or surrogate key) for equals()

Hi,

I am thinking of using surrogate key (the one generated by
database) to implement equals() of domain object for ibatis. 

Now is there any pitfall I need to know???

Anyone doing things this way??

Although 'Hibernate in Action' said this is a bad idea but
I only want to compare objects that have id so I guess
this shud be ok.

Thanks,

Sam

Re: isPropertyAvailable doesn't work as expected...

Posted by ib...@aladin.ca.
Problem solved: use <sql> and <include>.

Aladin


>
> I have two simple queries which I am trying to combine using
> <isPropertyAvailable...> but it doesn't seem to work as expected.
>
> Query 1: SELECT requestid FROM users WHERE name = 'test'
> Query 2: SELECT count(*) FROM users WHERE name = 'test'
>
> IN XML:
> =======
> <select id="getResult" resultClass="java.util.Hashtable"
> cacheModel="memory-cache">
> SELECT
> <isPropertyAvailable property="count"> count(*) </isPropertyAvailable>
> <isNotPropertyAvailable property="count"> requestid
> </isNotPropertyAvailable>
> FROM users WHERE name = 'test'
> </select>
>
> RESULT:
> =======
> [DEBUG] - Query key=getResult, params={} (getObjects)
> [DEBUG] - Query key=getResult, params={count=count} (getObjects)
> [ERROR] -
> --- The error occurred in queries.xml.
> --- The error occurred while applying a result map.
> --- Check the getResult-AutoResultMap.
> --- Check the result mapping for the 'requestid' property.
> --- Cause: org.postgresql.util.PSQLException: The column name requestid
> was not found in this ResultSet. (getObjects)
>
> I always get an error in the second query I call.  Am I missing something
> here?
>
> Thanks.
> Aladin
>


Re: isPropertyAvailable doesn't work as expected...

Posted by Jeff Butler <je...@gmail.com>.
You'll have to do remapResults="true" in this case - because you are
changing the result set in the same query.

Jeff Butler


On 6/15/06, ibatis@aladin.ca <ib...@aladin.ca> wrote:
>
> Hello,
>
> I have two simple queries which I am trying to combine using
> <isPropertyAvailable...> but it doesn't seem to work as expected.
>
> Query 1: SELECT requestid FROM users WHERE name = 'test'
> Query 2: SELECT count(*) FROM users WHERE name = 'test'
>
> IN XML:
> =======
> <select id="getResult" resultClass="java.util.Hashtable"
> cacheModel="memory-cache">
> SELECT
> <isPropertyAvailable property="count"> count(*) </isPropertyAvailable>
> <isNotPropertyAvailable property="count"> requestid
> </isNotPropertyAvailable>
> FROM users WHERE name = 'test'
> </select>
>
> RESULT:
> =======
> [DEBUG] - Query key=getResult, params={} (getObjects)
> [DEBUG] - Query key=getResult, params={count=count} (getObjects)
> [ERROR] -
> --- The error occurred in queries.xml.
> --- The error occurred while applying a result map.
> --- Check the getResult-AutoResultMap.
> --- Check the result mapping for the 'requestid' property.
> --- Cause: org.postgresql.util.PSQLException: The column name requestid
> was not found in this ResultSet. (getObjects)
>
> I always get an error in the second query I call.  Am I missing something
> here?
>
> Thanks.
> Aladin
>

Re: isPropertyAvailable doesn't work as expected...

Posted by puneet arya <pu...@yahoo.co.in>.
hi,
     Y dnt you use join statement for this.

ibatis@aladin.ca wrote:
  Hello,

I have two simple queries which I am trying to combine using
but it doesn't seem to work as expected.

Query 1: SELECT requestid FROM users WHERE name = 'test'
Query 2: SELECT count(*) FROM users WHERE name = 'test'

IN XML:
=======
cacheModel="memory-cache">SELECT count(*)  requestid FROM users WHERE name = 'test'

RESULT:
=======
[DEBUG] - Query key=getResult, params={} (getObjects)
[DEBUG] - Query key=getResult, params={count=count} (getObjects)
[ERROR] -
--- The error occurred in queries.xml.
--- The error occurred while applying a result map.
--- Check the getResult-AutoResultMap.
--- Check the result mapping for the 'requestid' property.
--- Cause: org.postgresql.util.PSQLException: The column name requestid
was not found in this ResultSet. (getObjects)

I always get an error in the second query I call. Am I missing something
here?

Thanks.
Aladin


 				
---------------------------------
  Yahoo! India Answers: Share what you know. Learn something new Click here
 Send free SMS to your Friends on Mobile from your Yahoo! Messenger Download now

isPropertyAvailable doesn't work as expected...

Posted by ib...@aladin.ca.
Hello,

I have two simple queries which I am trying to combine using
<isPropertyAvailable...> but it doesn't seem to work as expected.

Query 1: SELECT requestid FROM users WHERE name = 'test'
Query 2: SELECT count(*) FROM users WHERE name = 'test'

IN XML:
=======
<select id="getResult" resultClass="java.util.Hashtable"
cacheModel="memory-cache">
SELECT
<isPropertyAvailable property="count"> count(*) </isPropertyAvailable>
<isNotPropertyAvailable property="count"> requestid </isNotPropertyAvailable>
FROM users WHERE name = 'test'
</select>

RESULT:
=======
[DEBUG] - Query key=getResult, params={} (getObjects)
[DEBUG] - Query key=getResult, params={count=count} (getObjects)
[ERROR] -
--- The error occurred in queries.xml.
--- The error occurred while applying a result map.
--- Check the getResult-AutoResultMap.
--- Check the result mapping for the 'requestid' property.
--- Cause: org.postgresql.util.PSQLException: The column name requestid
was not found in this ResultSet. (getObjects)

I always get an error in the second query I call.  Am I missing something
here?

Thanks.
Aladin