Hi Armin:
I already tested the patch (in our application and using OJB junit). The
patch and seems to be working good. Attached is new eclipse generated
patch. It is the same as yours, but in a eclipse format to be easily
applied by anyone (right click on project team -> Apply patch....)
I tried to go into the Identity "web" and as you told it is very dificult
to get a truly solutions. Seems like Identity and related helpers methods
needs to be refactored.
Thanks again for help us in this problem. :-DD
Best regards,
Antonio Gallardo.
On Mie, 12 de Enero de 2005, 19:05, Armin Waibel dijo:
>
>
> Antonio Gallardo wrote:
>> Hi Armin!
>>
>> Thanks for the replies! I was talking with Carlos and we think this is a
>> bug because we are quering and we will not expect changes on the
>> database
>> while quering. Suppose someone is using a read-only one (on a CDROM)?
>>
>> Checking in the RDBMS world, if we ask for:
>>
>> SELECT count(*) FROM clients where cli_id = null;
>>
>> The answer is 0 rows. No errors and not touched the Sequence at all.
>>
>> Few minuts ago, Carlos tested other cases, for example, what could
>> happen
>> if we are not using a sequence at all?
>> Answer: In this case, returns null! That is cool. :-D
>>
>> In conclusion, we found that if we don't use sequences at all then:
>>
>> if PK=null or PK!=null but the PK value does not match to a table row
>> PK,
>> then it returns null. So that is what we could expect in the case of
>> using
>> sequences.
>>
>> WDYT?
>>
>> Can you send me some hints, where I can find the classes and I will try
>> to
>> fix this small problem? ;-)
>>
>
> Have a look at PersistenceBrokerImpl line 1527.
>
> I attached a fix that should work (not tested).
>
> The main problem was Identity class. This class obtain new id's and set
> the PK values in the persistent object (if PK fields are null). In my
> opinion this should not happen (bad design), but to change this will be
> costly.
>
> regards,
> Armin
>
>
>> Best Regards,
>>
>> Antonio Gallardo.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
>>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
Index: PersistenceBrokerImpl.java
===================================================================
RCS file:
/home/cvspublic/db-ojb/src/java/org/apache/ojb/broker/core/PersistenceBrokerImpl.java,v
retrieving revision 1.83.2.9
diff -u -r1.83.2.9 PersistenceBrokerImpl.java
--- PersistenceBrokerImpl.java 12 Dec 2004 01:49:43 -0000 1.83.2.9
+++ PersistenceBrokerImpl.java 13 Jan 2005 09:59:18 -0000
@@ -1524,20 +1524,24 @@
*/
public Object getObjectByQuery(Query query) throws
PersistenceBrokerException
{
+ Object result = null;
if (query instanceof QueryByIdentity)
{
// example obj may be an entity or an Identity
Object obj = query.getExampleObject();
- Identity oid = null;
if (obj instanceof Identity)
{
- oid = (Identity) obj;
+ Identity oid = (Identity) obj;
+ result = getObjectByIdentity(oid);
}
else
{
- oid = new Identity(obj, this);
+ if
(!serviceBrokerHelper().hasNullPKField(getClassDescriptor(obj.getClass()), obj))
+ {
+ Identity oid = serviceIdentity().buildIdentity(obj);
+ result = getObjectByIdentity(oid);
+ }
}
- return getObjectByIdentity(oid);
}
else
{
@@ -1548,7 +1552,6 @@
resources instantly
*/
OJBIterator it = getIteratorFromQuery(query, cld);
- Object result = null;
/*
arminw:
patch by Andre Clute, instead of taking the first found result
@@ -1571,8 +1574,8 @@
{
if(it != null) it.releaseDbResources();
}
- return result;
}
+ return result;
}
/**
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]