Javadogs,Based on this discussion, I'd like to propose that we restrict projections to single-valued fields. What this means is that a specification-compliant implementation must be able to throw an exception if users try to project a multi-valued field or an aggregate of a multi-valued field.
If an implementation wants to allow users to project a multi-valued field, they need to have the user set some configuration option, e.g. org.errant.jdoimpl.option.query.MultiValuedFieldProjectionUseAtYourImmed iateRisk. The TCK would run without this option set.
Objections? Craig <proposed> Specifying the Result of a Query (Projections, Aggregates)The application might want to get results from a query that are not instances of the candidate class. The results might be single-valued fields of persistent instances, instances of classes other than the candidate class, or aggregates of single-valued fields.
</proposed> On Feb 15, 2006, at 11:31 AM, [EMAIL PROTECTED] wrote:
Hi Wes,Since an association has no identity, I would expect Collection.equals using JDOidentity of the elements and owner, meaning 1 result.IMO, we don't have to define these semantics unless they are going to be set inthe spec. Regards, Erik Bengtson Quoting Wes Biggs <[EMAIL PROTECTED]>:I still contend that "distinct" does not imply the .equals() operator,and thus the answer would be Collection1 [emp1,emp2,emp3] Collection2 [emp1,emp2,emp3] Where Collection1 != Collection2 even though Collection1.equals(Collection2). Consider an employee database with two men named John Smith and datastore identity in use. I would expect "select distinct this from Employee where name=='John Smith'" to return 2 results. Wes [EMAIL PROTECTED] wrote:Hi Bin,or result 2: [emp1,emp2,emp3]The result would be 2 IMO according to what collection.equals contract says.For distinct queries, The easiest way is to evaluate it in memory. Ofcourse,optimal solutions may still apply.For non distinct queries, that's very simple and collections can be lazyloaded.Quoting Bin Sun <[EMAIL PROTECTED]>:Hi, Erik! I mean which would be the result? result 1: [emp1,emp2,emp3] [emp1,emp2,emp3] or result 2: [emp1,emp2,emp3] ? If SQL 'distinct' used, we'll get result 1, I guess. But as 'distinct' defined, the result should be result 2, like a 'distinct name' query. --- [EMAIL PROTECTED] wrote:Bin, Using distinct keyword the most database independent would be doing that in memory, but for some databases you can create stored procedures or UDFs. Regards, Quoting Bin Sun <[EMAIL PROTECTED]>:Hi, erik! I'm curious. If we have two departments: dept1 has employees: emp1, emp2, emp3 dept2 has employees: emp1, emp2, emp3 (assume 'employees' is not a many-to-one relation) What will be the result of: (one or two result row(s)?) select distinct employees from Department and what SQL would be generated? --- [EMAIL PROTECTED] wrote:-1. I vote for non-portable. It's simple to implement. Quoting Craig L Russell <[EMAIL PROTECTED]>:Javadogs, If none of the implementations supportsprojections of collections ormaps, we can simply disallow it. If some dosupport it, we can sayit's not portable. For now, I'll propose disallowing it, and ifthereareimplementations out there we can change tonon-portable.<proposal 14.6.9> Specifying the Result of a Query (Projections,Aggregates)The application might want to get results fromaquery that are notinstances of the candidate class. The resultsmight be single-valuedfields of persistent instances, instances ofclasses other than thecandidate class, or aggregates ofsingle-valuedfields.</proposal 14.6.9> Craig On Feb 13, 2006, at 8:58 PM, Craig L Russellwrote:Hi Bin, I think it's confusing to project acollectionor map in a query.The reason is that if there is a variablethatderives from thesame field as is being projected, the usermightthink that thefield will be subject to the sameconstraints asthe query, butthis would be wrong. I'd rather we restrict projections ofcollectionand map inqueries. We can always add it later once wethink more aboutwhether it makes sense and has a strongjustification.What can the user not do today if werestrictprojection ofcollections and maps? If the user reallywantsto navigate to thecollection or map field, then just projecttheinstance andnavigate to the fields of interest. Craig On Feb 13, 2006, at 6:27 PM, Bin Sun wrote:Hi, all! Did anyone notice this? --- Bin Sun <[EMAIL PROTECTED]> wrote:Hi! I have more concern about CollectionandMapprojection: is this query easy toimplement?select distinct employees from Departmentwhere ...At least I don't know how a SQL datastorecouldcompare the collections one another. So, maybe we should discribe more onCollectionand Map projection, or simply specify thattheirdistinction is the same as their ownerobjects,dispite whether they equal one another. --- [EMAIL PROTECTED] wrote:Thanks for the comments, I agree with youall.Regards, Quoting Michael Bouschen<[EMAIL PROTECTED]>:Hi, I have the same understanding of thesemanticsofprojections ofcollection and map fields as Wes and BinSun.Thequery would return thecollections or maps as single cells, sothequeryresult would be a listof collections or maps. I also agreethatsupportfor projections ofcollection and map fields does not addmuchvalue,but AFAIK the currentspec allows this. I think the shape of the query result isdifferentwhether projecting acollection field or including a variableintheresult that iterates thecollection: (1) SELECT employees FROM Department (2) SELECT e FROM Department WHEREemployees.contains(e)The first query returns a list ofcollections ofemployees, so for eachdepartment it returns the department'semployeecollection. Query (2)returns a list of employees, where eachreturnedemployee is included inan employee collection of at least onedepartment.Given the above is correct, JDOQL wouldneverreturn Map.Entryinstances. Either the query projects theentiremap or it iterates themap using containsKey or containsValue,butthereis no contains for maps.=== message truncated === __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com
Craig Russell Architect, Sun Java Enterprise System http://java.sun.com/products/jdo 408 276-5638 mailto:[EMAIL PROTECTED] P.S. A good JDO? O, Gasp!
smime.p7s
Description: S/MIME cryptographic signature
