-->
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.  [ 3 posts ] 
Author Message
 Post subject: Performance Issues on Reflection and Cross-Reference on VO´
PostPosted: Tue May 30, 2006 10:04 am 
Newbie

Joined: Tue May 30, 2006 10:01 am
Posts: 1
In this example whe have an onte-to-many relationship from item to title
Advisers have given me two ways to do it:

Query example. Load an item with x code, showing title and item data on page.


1- Referencies and documentation found on Hibernate Hibernate Forum / Hibernate Reference / Hibernate in Action and how i using it
To load an item we have to load ItemVO and get to title by ItemVO relationship (ItemVO.getTitle )

HQL made to load one item:

HQL = " FROM ITEMVO AS VO WHERE VO.ID = 10 "

Here we get title from the relationship with item


2 - Second opinion shown by some people who uses hibernate

Note: This people use that way because they feel that reflection is too havy on processing issues, so this second form is the best
performance one by their tought.

- Never use cross-reference, on VO´s (POJO´s). To load an item we have to iterate on title collection to get to item we want. :(

HQL to load one TITLE:
HQL = " FROM TITLE AS VO "

Iterator it = title.item.iterator();
while (it.hasnext() ) {

itemVO = (ItemVO) it.next();
if ( title.item.id = 10 )
{
xItemVO x = itemVO;
break;
}

}


When using the option 1 i know all the benefits that hibernate give to us
When using the option 2 wich benefit can i get from using hibernate ?

Note: We want this question be discussed for the extense off it, to all of us of the Java Community, to get on this mather and if we can create an pattern
of development. Of course in some cases we could get the second solution to work, but IMO is not the best way.

Thanks in advance


-------------------------------------------------------


/**
* @hibernate.class table="ITEM"
*
*/
public class ItemVO
{

...

/** persistent field */
private TitleVO title;

...

/**
* @hibernate.many-to-one not-null="true"
* @hibernate.column name="idTitle"
*
*/
public TitleVO getTitle()
{
return this.title;
}

public void setCapFatheader(TitleVO title)
{
this.title = title;
}

...


}


/**
* @hibernate.class
* table="TITLE"
*
*/
public class TitleVO {

...


/** persistent field */
private Collection item;

...

/**
* @hibernate.bag
* lazy="true"
* @hibernate.collection-key
* column="id"
* @hibernate.collection-one-to-many
* class="xx.xx.ItemVO"
*
*/
public Collection getItem() {
return this.Item;
}

public void setItem(Collection item) {
this.item = item;
}

...

}

_________________
www.infosist.com.br


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 30, 2006 11:32 am 
Newbie

Joined: Tue May 30, 2006 10:25 am
Posts: 1
Dear fguerios

If I have understood your question, I think that, in this case, reflection is not an important issue developers should worry about.

Instead, IMHO, we should spend our time thinking about a way to standardize the code. If you choose one way, then the whole team should follow it, not matter which way.

By the way, I think the first solution is the best because it is the way Hibernate do things and it is a nice OO way to standardize code. In the background, who garantees that Hibernate is not doing things like the second solution?

Marcos R. P.


Top
 Profile  
 
 Post subject: Performance
PostPosted: Tue May 30, 2006 11:41 am 
Newbie

Joined: Tue May 30, 2006 11:24 am
Posts: 1
Location: Curitiba
Well, i can not think someone use the second form of code.
Some points to think about:
-On the first mode:
"from someVO vo where vo.id ='10'"
A lot of work will be executed by DB using indexes and a lot of other features.
-On the second example:
Iterator it ...
A lot of record will come from database (that can be, and usually is, in an other machine) causing a heavy trafic on the network.
To access the items of the list, a lot of jumps on the memory will be necessary, and all that whithout the help of indexes, etc...



-The reflection wont be used all times.
The best practices that is used today works manipulating the byte codes and with the help of Just In Time Compilers will turn the reflection ligth.
Exists a lot of points to write here, i think the firstones are enought.

*If the mount of data is unsignificant for the trafic and jumps, everyone of the two issues is actually good the twoones will be fast.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.