emmanuel wrote:
if by fetch group you mean the ability to fetch properties, then this feature is mostly useless IMO. If by fetch group you mean the ability to fetch associations, then use a JPA-QL query and add the fetch keyword depending on what association you want to fetch.
I'd like to fetch association, i'd like to specify an object graph to fetch, like i see it's possible using joins... for example load user with his shop basket
i read
http://www.hibernate.org/hib_docs/entit ... ryhql.html
at 7.3
is there a way to disabilitate a join? i thougt to generate a query with all possible joins and then abilit only interested... but i think this solution s**k
and i'd like to have such query generated...
another way is to create named query at startup/runtime... or cache compiled query
at this time i got to generate simple named query for my pojo by ant task & custom template...
in org\hibernate\hibernate-mapping-3.0.dtd
i see the
loader element:
<!-- The loader element allows specification of a named query to be used for fetching
an entity or collection -->
<!ELEMENT loader EMPTY>
<!ATTLIST loader query-ref CDATA #REQUIRED>
<!-- The query element declares a named Hibernate query string -->
<!ELEMENT query (#PCDATA|query-param)*>
<!ATTLIST query name CDATA #REQUIRED>
<!ATTLIST query flush-mode (auto|never|always) #IMPLIED>
<!ATTLIST query cacheable (true|false) "false">
<!ATTLIST query cache-region CDATA #IMPLIED>
<!ATTLIST query fetch-size CDATA #IMPLIED>
<!ATTLIST query timeout CDATA #IMPLIED>
<!ATTLIST query cache-mode (get|ignore|normal|put|refresh) #IMPLIED>
<!ATTLIST query read-only (true|false) #IMPLIED>
<!ATTLIST query comment CDATA #IMPLIED>
seems to me that i can put in a hbm file my named query.. seems nice... but i use code generation :( so every time i have to rewrite...
i'm quite friendly with freemaker template... so i'd like to know if this way is reasonable... i copy from cayenne code generation:
i generate a pojo in abstract class... i mean... the class is the same but is declared abstract...
then i generate a corrisponding pojo empty concrete class that extend the abstract class... in this concrete class i put all my custom named query....
at first i generate both abstract & concrete class.. then i generate only abstract class...
i hope i explained my ideas...
Thanks!!!