-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 posts ] 
Author Message
 Post subject: How To implements Fetch Group like JDO?
PostPosted: Wed Jul 19, 2006 8:59 am 
Newbie

Joined: Wed May 31, 2006 6:40 am
Posts: 19
Hibernate version:
Ejb3 backed up by hibernate boundled with jboss 4.0.4 GA i think it's 3.20 cr2

I'd like the Fetch Group feature in JDO.... i'm using Ejb3 and i'd like to have a way to build a fetch group...
i generate the code using Hibernate Tools i'd like to add a methond like

public User findUserWithFetchGroup(FetchGroup fetchGroup,Map ParametersMap)

or at least

public User findUserWithCustomEJBQL(String EJBQL, Map ParametersMap)

and Also....
EJB3 (stateless) bean require to implement an interface... Hibernate Tools don't provide it.. so i try to modify freemaker template... but i don't have the binding... for example i see ${pojo...} but i don't know what kind of object is... or how can i extend with an interface template.....

Thank To all!!!


Last edited by icecuber on Thu Jul 20, 2006 12:18 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 20, 2006 4:28 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
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.

_________________
Emmanuel


Top
 Profile  
 
 Post subject: Named Query? cache compiled query at runtime? (quite long)
PostPosted: Thu Jul 20, 2006 11:55 am 
Newbie

Joined: Wed May 31, 2006 6:40 am
Posts: 19
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!!!


Top
 Profile  
 
 Post subject: Re: Named Query? cache compiled query at runtime? (quite lon
PostPosted: Mon Jul 24, 2006 5:05 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
icecuber wrote:
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


I'm having hard time understanding you but create one query by usecase, you don't have all possible combination of use cases, do you?

An alternative is to use the Hibernate criteria query and define the setFetchMode() programmatically

_________________
Emmanuel


Top
 Profile  
 
 Post subject: Re: Named Query? cache compiled query at runtime? (quite lon
PostPosted: Wed Jul 26, 2006 3:54 am 
Newbie

Joined: Wed May 31, 2006 6:40 am
Posts: 19
emmanuel wrote:
icecuber wrote:
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


I'm having hard time understanding you but create one query by usecase, you don't have all possible combination of use cases, do you?

An alternative is to use the Hibernate criteria query and define the setFetchMode() programmatically


Is it possible to use setFetchMode() in EJB3?? How? is there a documentation? since now i didn't find anything like this...

i try to explain better what i'd like to do...

i'd like to define some custom query that fetch all associations i need to detach the object in relation with the current operation.... for example a query for getting a user with all active ShoppingBasket and another query for getting a user with all PurchasingOrder and so on....

and for performance reason... i'd like to cache query in compiled form...

I'm using the ant tasks with some custom template to auto-generate pojo(entity), dao(home) & interfaces for ejb3...

[OT]is it possible to merge auto-generated code with custom code?
for example i'd like to define class by classs some custom query in revenge or in configuration...

With my custom templates i put in pojos all the named queries i can generate automatically something like
"selectAllUser" & "selectUserByUsername" and so on...

i like named query because they are compiled at startup and cached in compiled form... i think this give me a performance boost since a "normal" query needs to be compiled every time...

However... is not possible to add or modify a named query at runtime right? i think that modify a query at runtime could save my day since i can solve some problem without restart my enterprise application

So... Is it possible to have a query cache?

Thanks in advice


Top
 Profile  
 
 Post subject: Re: Named Query? cache compiled query at runtime? (quite lon
PostPosted: Wed Jul 26, 2006 3:11 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
icecuber wrote:
i like named query because they are compiled at startup and cached in compiled form... i think this give me a performance boost since a "normal" query needs to be compiled every time...


Did you actually experience somes performance drawbacks? I bet no because Hibernate does cache queries whether they are named queries or not. I guess that saves your day :-)[/quote]

_________________
Emmanuel


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.