RE: [Hibernate] New HQL features in CVS

2005-04-04 Thread Cameron Braid
Fantastic - That is exactly what I want :)

I'd also like to see this :

 map creation from specified key and value columns (either key,value or
aliased)

select new keyedmap ( order.id as key, order as value) from Order order
select new keyedmap ( order.id, order ) from Order order

However this doesn't fit the [List find(String] interface of session
A soloution may be to return a list of 1 element that contains the map


 plugable loaders

Allow user defined loaders (or object factories) rather than hibernate
creating the instances 

i.e.

Configuration.registerLoader('customLoader', new CustomLoader());

select load customLoader( order.id as id, order.key as key, order ) from ...

interface Loader {
Object load(String[] aliases, Object[] aliasedValues, Object[]
positionalValues)
}

Hibernate would call load([id, name], [1, SFG34AF], [orderInstance])
for each row


 JavaBean construction from aliased properties

class OrderView {
long id,
Customer customer
// getters and setters
}

select new OrderView(o.id as id , o.customer as customer) from Order o

The loader will create a new OrderView instance from the default
constructor, and set the properties using the alias names 

Could have plugable loaders - JavaBeanPropertyLoader, FieldAccessLoader
etc.. issue : could these be specifyable per query ?  if so, how ?


This could probably be implemented with the custom loader idea above

select load javaBeanLoader( 'com.whatever.OrderView' as class, o.id as id,
o.customer as customer ) from Order o

however this syntax isn't purfect.



 final thoughts

After writing this, some of this can probably be supported outside of
hibernate by getting hibernate to return a list of maps and transforming
this using a custom transformer.  One advantage of getting hibernate to do
it would be the creation of less garbage.

Just my 2c worth.

Cameron

 -Original Message-
 From: [EMAIL PROTECTED] [mailto:hibernate-devel-
 [EMAIL PROTECTED] On Behalf Of Gavin King
 Sent: Tuesday, 5 April 2005 2:07 PM
 To: 'hibernate-devel@lists.sourceforge.net'
 Subject: [Hibernate] New HQL features in CVS
 
 
   select foo.bar as fb, foo.x as fx from Foo foo ( use together with
 Query.getReturnAliases() )
 
   select new list(foo.bar, foo.x) from Foo foo
 
   select new map( foo.bar as fb, foo.x as fx) from Foo foo
 
 
 Enjoy!
 
 --
 Gavin King
 +61 410 534 454
 +1 404 822 8349
 callto://gavinking
 
 Hibernate
 [EMAIL PROTECTED]
 http://hibernate.org
 
 JBoss Inc
 [EMAIL PROTECTED]
 http://jboss.com
 
 
 
 ---
 SF email is sponsored by - The IT Product Guide
 Read honest  candid reviews on hundreds of IT Products from real users.
 Discover which products truly live up to the hype. Start reading now.
 http://ads.osdn.com/?ad_id=6595alloc_id=14396op=click
 ___
 hibernate-devel mailing list
 hibernate-devel@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/hibernate-devel



---
SF email is sponsored by - The IT Product Guide
Read honest  candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595alloc_id=14396op=click
___
hibernate-devel mailing list
hibernate-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/hibernate-devel


RE: [Hibernate] New HQL features in CVS

2005-04-04 Thread Gavin King
 map creation from specified key and value columns (either key,value
or
aliased)

-1, I don't see this as a general need; you can always use a criteria
query with a resultTransformer (I'm currently resisting the idea of
adding ResultTransformer to the HQL facility).


 plugable loaders

Well, between custom persisters, CustomQuery and the new loader
query-ref 
stuff, there is already an enormous amount of flexibility here. It would
take a lot to convince me that there is some case that can't be handled.


 JavaBean construction from aliased properties

yes, this is on my TODO list. It is straightforward. Patches are very
welcome.



---
SF email is sponsored by - The IT Product Guide
Read honest  candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_ide95alloc_id396op=click
___
hibernate-devel mailing list
hibernate-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/hibernate-devel