cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jakub Kaniewski <j...@egonet.pl>
Subject Re: Using Hibernate via Java, not Flow
Date Thu, 14 Apr 2005 18:53:10 GMT
beyanet.com wrote:

>
> I use hibernate within JBoss 4 as follows:
>
>              InitialContext ctx = new InitialContext();              
> sessionfactory = 
> (SessionFactory)ctx.lookup("java:/hibernate/SessionFactory");          
> session = sessionfactory.openSession();          transaction = 
> session.beginTransaction();          orderSet = 
> (Order)session.load(Order.class, orderNum); 
> Hibernate.initialize(orderSet.getOrderItems());              
> transaction.commit(); session.close();
>
> for example.
>
Yeah I though about this method, but it is rather complicated if I must 
initialize more complicated data structures. For example if I have beans 
OWNER,DOG,AWARD, where relation is - owner have many dogs, dog have many 
award. If I use lazy initialization I can easy print out everything. But 
I resign from lazy loading I must initialize collections by hand. So If 
have a owner I should initialize DOGS Collection. It is easy -> 
Hibernate.initialize(owner.getDogs()). But in next step I want to 
initialize all dog awards, to do that I must Iterate through getDogs 
Collection.

Iterator<Dog> it = owner.getDogs().iterator();
while (it.hasNext())  Hibernate.initialize(it.next);

So it is bit more complicated. But if we have more nested elements we 
want access the initialization become madness. So I think it is not 
worth to resign from lazy loading.

J.K.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Mime
View raw message