Post #156,396
5/22/04 5:08:32 PM
|

Re: response 2
I posted one I would like to see in a nearby message. The "GPA" one. I'm talking about persistence, not reporting. Hammers for nails, screwdrivers for screws. I'd probably use a stored procedure to obtain a single number like that. But since you asked, Hibernate supports aggregates as well. Float avg = single("select avg(grade) from (select avg(student.grades) as grade from Student student)"); Note the absence of a group by. Very similar, otherwise.
Regards,
-scott anderson
"Welcome to Rivendell, Mr. Anderson..."
|
Post #156,407
5/22/04 5:44:46 PM
|

Re Re: response 2
Float avg = single("select avg(grade) from (select avg(student.grades) as grade from Student student)"); You are passing a string of an SQL-like query language, but it is not SQL. Is this correct? Why invent another query language that is sort of like SQL? People already know SQL. (I agree that SQL is not the ideal relational language, but until a better standard is established, it is good enough.) I'm talking about persistence, not reporting. I am not sure what you are getting at then. Note that data dictionaries make a nice place to put info about converting fields into data columns, such as DB column type, length limits, etc. Ideally that perhaps should be stored in the RDBMS schemas, but vendors don't support extending that stuff for some reason.
________________ oop.ismad.com
|
Post #156,409
5/22/04 5:58:10 PM
|

HQL is a superset of SQL
HQL understands inheritance and polymorphism. Joins are made automatically based on foreign key references. You'll note the lack of a group by in the previous example; that is significant. It also allows selection of grouped bodies of data without specification: select parent from Post; - selects all of the data as a Parent object, without needing to specifiy what that entails. It allows formation of objects on the fly through the query language as well: select new Foo(a, b, c) from Bar; - creates a new Foo object as a subset of a Bar object. Queries without joins: from Post as post where post.parent.subject like '%response%'; from Post as post where post.forum.board.owner = ?; Note that, with caching, some of the above can be resolved entirely in memory without a trip to the database. Test sizes of collections: from Forum as forum where forum.posts[0].responses.size > 42; - find all forums where the first post in the forums has more than 42 responses. Here's a good one from the Hibernate docs: select cust\nfrom Product prod,\n Store store\n inner join store.customers cust\nwhere prod.name = 'widget'\n and store.location.name in ( 'Melbourne', 'Sydney' )\n and prod = all elements(cust.currentOrder.lineItems)\n\nvs.\n\nSELECT cust.name, cust.address, cust.phone, cust.id, cust.current_order\nFROM customers cust,\n stores store,\n locations loc,\n store_customers sc,\n product prod\nWHERE prod.name = 'widget'\n AND store.loc_id = loc.id\n AND loc.name IN ( 'Melbourne', 'Sydney' )\n AND sc.store_id = store.id\n AND sc.cust_id = cust.id\n AND prod.id = ALL(\n SELECT item.prod_id\n FROM line_items item, orders o\n WHERE item.order_id = o.id\n AND cust.current_order = o.id\n )\n
Regards,
-scott anderson
"Welcome to Rivendell, Mr. Anderson..."
|
Post #156,429
5/22/04 7:11:18 PM
|

re: HQL is a superset of SQL
Joins are made automatically based on foreign key references. Some RDBMS SQL dialects provide this ability also I hear, but I have yet to try it. Here's a good one from the Hibernate docs: .... Hmmm. Interesting. It uses "dot paths", such as "store.location.name". Anyhow, suppose this HQL is the greatest query language since sliced bread and really does isolate one from specific RDBMS vendors. Couldn't one just use HQL in place of SQL in procedural code without the rest of the OR-mapper stuff? (Assuming ER info is given via meta data.) You are doing a better job at selling a query language than you are at selling OR-mappers, and so far they generally seem like orthogonal things.
________________ oop.ismad.com
|
Post #156,432
5/22/04 7:17:45 PM
|

re: HQL is a superset of SQL
The query language is integral to the O-R mapper, and vice versa, in that it returns objects.
Regards,
-scott anderson
"Welcome to Rivendell, Mr. Anderson..."
|
Post #156,440
5/22/04 7:44:37 PM
|

Forced to use A to get B? Tsk tsk tsk. How MS of them.
________________ oop.ismad.com
|
Post #156,441
5/22/04 7:46:46 PM
|

You miss the point, anyway.
HQL can be used against any database engine.
Regards,
-scott anderson
"Welcome to Rivendell, Mr. Anderson..."
|
Post #156,451
5/22/04 9:17:03 PM
|

I am not necessarily disagreeing with that here
I am only saying that a better and/or vender-neutral query language/system is or can be orthogonal to O-R mappers.
________________ oop.ismad.com
|
Post #156,455
5/22/04 9:49:59 PM
|

Re: I am not necessarily disagreeing with that here
At this point, it is not orthogonal. It exists for Hibernate, and it was easy to write because of OO. If you disagree, prove me wrong. Otherwise concede the point.
Regards,
-scott anderson
"Welcome to Rivendell, Mr. Anderson..."
|
Post #156,461
5/23/04 12:08:31 AM
5/23/04 12:10:06 AM
|

not my burden of evidence
It exists for Hibernate, and it was easy to write because of OO. If you disagree, prove me wrong. Otherwise concede the point. By "easy to write", do you mean using the framework or making the framework? You have the burden of showing something being "easy". Remember: "Equal, subjective, or unknown until proven otherwise". I can accept that my preferences may be purely a subjective mindfit. If you believe OO is some universal truth and/or a slum-dunk improvement, then it is your burden to show it.
________________ oop.ismad.com

Edited by tablizer
May 23, 2004, 12:10:06 AM EDT
|
Post #156,464
5/23/04 12:37:46 AM
|

Wrong.
Hibernate exists. Your mythical über SQL doesn't. If your version is even as good, let alone better, then you need to show it. Otherwise it's vaporware.
Now go answer or concede the other points.
Regards,
-scott anderson
"Welcome to Rivendell, Mr. Anderson..."
|
Post #156,468
5/23/04 12:56:18 AM
|

exist != good
Hibernate exists. Your mythical \ufffdber SQL doesn't. If your version is even as good, let alone better, then you need to show it. Otherwise it's vaporware. Mere existence does not necessarily lead to goodness. You need to explain why it is so good using code. Show me something that procedural or raw SQL MUST result in a mess with. Nor am I going to compete with an army of programmers to build a clone of Hibernate all by myself. That is not a realistic request. I can perhaps show specific aspects though. And being DB-neutral is moot because you are tied to Hibernate in a similar way. You are applying a double-standard.
________________ oop.ismad.com
|
Post #156,469
5/23/04 1:00:41 AM
|

Existence beats Non-Existence
|
Post #156,486
5/23/04 9:29:00 AM
|

I've already shown you.
Go answer or concede the other points.
Regards,
-scott anderson
"Welcome to Rivendell, Mr. Anderson..."
|
Post #156,491
5/23/04 10:21:45 AM
|

Hm. So I can make any claim and force you to prove me wrong?
You started this debate with some wild claims. Are you saying now "that was just subjective?" Remember: "Equal, subjective, or unknown until proven otherwise". Nice ideal. But they're in reverse order. If you want your claims to move from unknown/subjective to equal, the burden is on *you*. That's life. Suck it up.
|
Post #156,493
5/23/04 10:52:58 AM
5/23/04 10:53:33 AM
|

Actually, what he said was:
"You spend all your code translating back and forth between two discordant paradigms."
So he made a very specific claim in this instance. ;-)
Regards,
-scott anderson
"Welcome to Rivendell, Mr. Anderson..."

Edited by admin
May 23, 2004, 10:53:33 AM EDT
|
Post #156,410
5/22/04 5:58:53 PM
|

Persistence vs. reporting
Saving and retrieving students is persistence.
Performing aggregate queries on properties of students is reporting.
Regards,
-scott anderson
"Welcome to Rivendell, Mr. Anderson..."
|