[Hibernate] Query Counter Interceptor?

2003-11-24 Thread Eric Pugh
Hi all,

I am doing some performance tuning on my Hibernate based app.  I noticed
that a lot of my HQL is quite unoptimized, and requires many hits to the
database.  So I am using a combination of JunitPerf to monitor how long a
unit test takes and the show_sql to look at the number of SQL statements.

Which makes me wonder, has anyone written an interceptor that counts
individual queries to the database?  Basically I am looking for something
that reports back the number of queries by table:

Table   #   Type
Customer10  inserts
Customer, Workorder 5   selects
Status, Workorder   15  selects
Status  5   deletes


That way, I could then see if my tunings are helping.  I know the overall
count of selects isn't the perfect way to measure performance, but it is a
good gross indicator of performance.

Eric



---
This SF.net email is sponsored by: SF.net Giveback Program.
Does SourceForge.net help you be more productive?  Does it
help you create better code?  SHARE THE LOVE, and help us help
YOU!  Click Here: http://sourceforge.net/donate/
___
hibernate-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/hibernate-devel


[Hibernate] (no subject)

2003-11-24 Thread St-Pierre Philip





Hi everyone,
    I have an object named EntiteAffaire that has a collection (many-to-many relation with a composite-element) of coordinate. A coordinate can be a telephone, an address or an email. In the coordinate table, there is a field named "KIND_COO" that tells me which kind of coordinate is in the current row. Is it possible to specify a where clause for the set named entiteCoordonnees to get only one kind of coordinate in the set? This way, I would be able to defined three sets, one for each kind of coordinate. I succeed to specify a where clause that map to a field of the collection table (utl.t_entite_coordonnee_l), but not to the coordinate table, which is the end point of the relation.

    
        
            

        id>


        
            
            
            
                
                
            composite-element>
        set>
    class>


SQL> desc utl.t_entite_affaire;
 Name  Null?    Type
 -  
 ID_EA NOT NULL NUMBER(28)
 DATE_DERNIERE_MAJ NOT NULL TIMESTAMP(6)


SQL> desc utl.t_entite_coordonnee_l;
 Name  Null?    Type
 -  
 ID_COO    NOT NULL NUMBER(28)
 ID_EA NOT NULL NUMBER(28)
 REF_UTIL_COORD_EC NOT NULL VARCHAR2(19)
 DATE_DERNIERE_MAJ NOT NULL TIMESTAMP(6)


SQL> desc utl.t_coordonnee;
 Name  Null?    Type
 -  
 ID_COO    NOT NULL NUMBER(28)
 KIND_COO NOT NULL VARCHAR2(19)
 DATE_DERNIERE_MAJ NOT NULL TIMESTAMP(6)


I hope that my question is clear enough...


Philip St-Pierre
Loto-Québec - Projet IRIS (Centre de livraison)
Analyste-Programmeur
+ [EMAIL PROTECTED]







Re: [Hibernate] Query Counter Interceptor?

2003-11-24 Thread Juozas Baliuka

http://www.p6spy.com/
Try to query system views for statistics, it must help for performance
tuning too.

- Original Message -
From: "Eric Pugh" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, November 24, 2003 11:30 AM
Subject: [Hibernate] Query Counter Interceptor?


> Hi all,
>
> I am doing some performance tuning on my Hibernate based app.  I noticed
> that a lot of my HQL is quite unoptimized, and requires many hits to the
> database.  So I am using a combination of JunitPerf to monitor how long a
> unit test takes and the show_sql to look at the number of SQL statements.
>
> Which makes me wonder, has anyone written an interceptor that counts
> individual queries to the database?  Basically I am looking for something
> that reports back the number of queries by table:
>
> Table # Type
> Customer 10 inserts
> Customer, Workorder 5 selects
> Status, Workorder 15 selects
> Status 5 deletes
>
>
> That way, I could then see if my tunings are helping.  I know the overall
> count of selects isn't the perfect way to measure performance, but it is a
> good gross indicator of performance.
>
> Eric
>
>
>
> ---
> This SF.net email is sponsored by: SF.net Giveback Program.
> Does SourceForge.net help you be more productive?  Does it
> help you create better code?  SHARE THE LOVE, and help us help
> YOU!  Click Here: http://sourceforge.net/donate/
> ___
> hibernate-devel mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/hibernate-devel



---
This SF.net email is sponsored by: SF.net Giveback Program.
Does SourceForge.net help you be more productive?  Does it
help you create better code?  SHARE THE LOVE, and help us help
YOU!  Click Here: http://sourceforge.net/donate/
___
hibernate-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/hibernate-devel


[Hibernate] Design question: am I asking for trouble?

2003-11-24 Thread Bear Giles
A quick design question whether I'm asking for trouble

I have a class with self-referential sets.  Call it:

 class Person {
// @hibernate.identifier
private Long id;
// @hibernate.set table="parents"
//  key=child_id value=parent_id cascade="all"
private Set parents;
// @hibernate.set table="parents"
//  key=parent_id value=child_id cascade="all"
private Set children;
// @hiberate.set table="siblings"
//  key=id value="sibling_id" cascade="all"
 }
I don't have problems when I do an initial population of the 
database via db-utils, but I'm wondering if it's maintainable 
since editing one object necessarily modifies other objects.  Will 
this confuse hibernate?  (I want to say "no," but for me that's 
still an assumption.)  I know everything is fine once I reload 
everything from the database, but I'm not sure about the impact on 
a live system.

Example: I add Alice as a parent of Bob.  If I now load Alice from 
disk, she'll have Bob as a child.  But if Alice is already in 
memory how long until she lists Bob as a child?  Should I call 
'evict()' on Alice when Bob adds her as a parent, and if so what 
does that do to other references to her?

On a related note, the sets contain the ID of the associated 
objects.  This isn't a problem at the persistence layer, but the 
external representation needs the sets to contain Persons, not 
Longs.  Is there a conventional way of handling this, or is it 
just something that needs to be manually done when converting the 
object from internal to external representation?

Bear



---
This SF.net email is sponsored by: SF.net Giveback Program.
Does SourceForge.net help you be more productive?  Does it
help you create better code?  SHARE THE LOVE, and help us help
YOU!  Click Here: http://sourceforge.net/donate/
___
hibernate-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/hibernate-devel


[Hibernate] Filtering collections with where clause??

2003-11-24 Thread St-Pierre Philip
Title: Message



Hi everyone, 
    I have an 
object named EntiteAffaire 
that has a collection (many-to-many relation with a 
composite-element) of coordinate. A coordinate can be a telephone, an address or 
an email. In the coordinate table, there is a field named "KIND_COO" that tells me which 
kind of coordinate is in the current row. Is it possible to specify a where 
clause for the set named entiteCoordonnees to get only one kind of 
coordinate in the set? This way, I would be able to defined three sets, one for 
each kind of coordinate. I succeed to specify a where clause that map to a field 
of the collection table (utl.t_entite_coordonnee_l), but not to the 
coordinate table, which is the end point of the relation.
     
    
         
    
    
    
    id> 
    
     
    
    
         
    
    
    
    
     
    
    
    
     
    
    
    
         
    
    composite-element>     
    set> 
    class> 

SQL> desc utl.t_entite_affaire;  Name  
Null?    Type  -  
  ID_EA 
NOT NULL NUMBER(28)  DATE_DERNIERE_MAJ 
NOT NULL TIMESTAMP(6) 
SQL> desc utl.t_entite_coordonnee_l; 
 Name  
Null?    Type  -  
  ID_COO    
NOT NULL NUMBER(28)  ID_EA 
NOT NULL NUMBER(28)  REF_UTIL_COORD_EC 
NOT NULL VARCHAR2(19)  DATE_DERNIERE_MAJ 
NOT NULL TIMESTAMP(6) 
SQL> desc utl.t_coordonnee;  Name  
Null?    Type  -  
  ID_COO    
NOT NULL NUMBER(28)  KIND_COO 
NOT NULL VARCHAR2(19)  DATE_DERNIERE_MAJ 
NOT NULL TIMESTAMP(6) 
I hope that my question is clear enough... 

Philip 
St-Pierre Loto-Québec - Projet IRIS (Centre de livraison) Analyste-Programmeur + [EMAIL PROTECTED] 


Re: [Hibernate] Filtering collections with where clause??

2003-11-24 Thread Gavin King
Have you tried the where attribute of the  element?

St-Pierre Philip wrote:

Hi everyone,
I have an object named EntiteAffaire that has a collection 
(many-to-many relation with a composite-element) of coordinate. A 
coordinate can be a telephone, an address or an email. In the coordinate 
table, there is a field named "KIND_COO" that tells me which kind of 
coordinate is in the current row. Is it possible to specify a where 
clause for the set named entiteCoordonnees to get only one kind of 
coordinate in the set? This way, I would be able to defined three sets, 
one for each kind of coordinate. I succeed to specify a where clause 
that map to a field of the collection table (utl.t_entite_coordonnee_l), 
but not to the coordinate table, which is the end point of the relation.









   



 column="ID_COO"
 
class="com.iris.business.component.util.CoordonneeUtil"
 not-null="true" 
 cascade="all"/>




SQL> desc utl.t_entite_affaire;
 Name  Null?Type
 -  

 ID_EA NOT NULL NUMBER(28)
 DATE_DERNIERE_MAJ NOT NULL TIMESTAMP(6)

SQL> desc utl.t_entite_coordonnee_l;
 Name  Null?Type
 -  

 ID_COONOT NULL NUMBER(28)
 ID_EA NOT NULL NUMBER(28)
 REF_UTIL_COORD_EC NOT NULL VARCHAR2(19)
 DATE_DERNIERE_MAJ NOT NULL TIMESTAMP(6)

SQL> desc utl.t_coordonnee;
 Name  Null?Type
 -  

 ID_COONOT NULL NUMBER(28)
 KIND_COO NOT NULL VARCHAR2(19)
 DATE_DERNIERE_MAJ NOT NULL TIMESTAMP(6)

I hope that my question is clear enough...

*/Philip St-Pierre/*
Loto-Québec - Projet IRIS (Centre de livraison)
Analyste-Programmeur
+ [EMAIL PROTECTED]

--
Gavin King
JBoss Group
+61 410534454
http://hibernate.org


---
This SF.net email is sponsored by: SF.net Giveback Program.
Does SourceForge.net help you be more productive?  Does it
help you create better code?  SHARE THE LOVE, and help us help
YOU!  Click Here: http://sourceforge.net/donate/
___
hibernate-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/hibernate-devel


RE: [Hibernate] Design question: am I asking for trouble?

2003-11-24 Thread Schnitzer, Jeff
I have found that self-referential entities work just fine.  Just make
sure that you lazily load everything so that hibernate doesn't have to
load your entire object graph into memory with every call.  If you have
a single parent object with a getter/setter, you'll want to use proxies,
but if your relationships are all mapped with collections then just make
sure that lazy-load="true".

Jeff Schnitzer
[EMAIL PROTECTED]

> -Original Message-
> From: Bear Giles [mailto:[EMAIL PROTECTED]
> Sent: Monday, November 24, 2003 10:09 AM
> To: [EMAIL PROTECTED]
> Subject: [Hibernate] Design question: am I asking for trouble?
> 
> A quick design question whether I'm asking for trouble
> 
> I have a class with self-referential sets.  Call it:
> 
>   class Person {
>  // @hibernate.identifier
>  private Long id;
> 
>  // @hibernate.set table="parents"
>  //  key=child_id value=parent_id cascade="all"
>  private Set parents;
> 
>  // @hibernate.set table="parents"
>  //  key=parent_id value=child_id cascade="all"
>  private Set children;
> 
>  // @hiberate.set table="siblings"
>  //  key=id value="sibling_id" cascade="all"
>   }
> 
> I don't have problems when I do an initial population of the
> database via db-utils, but I'm wondering if it's maintainable
> since editing one object necessarily modifies other objects.  Will
> this confuse hibernate?  (I want to say "no," but for me that's
> still an assumption.)  I know everything is fine once I reload
> everything from the database, but I'm not sure about the impact on
> a live system.
> 
> Example: I add Alice as a parent of Bob.  If I now load Alice from
> disk, she'll have Bob as a child.  But if Alice is already in
> memory how long until she lists Bob as a child?  Should I call
> 'evict()' on Alice when Bob adds her as a parent, and if so what
> does that do to other references to her?
> 
> 
> On a related note, the sets contain the ID of the associated
> objects.  This isn't a problem at the persistence layer, but the
> external representation needs the sets to contain Persons, not
> Longs.  Is there a conventional way of handling this, or is it
> just something that needs to be manually done when converting the
> object from internal to external representation?
> 
> Bear
> 
> 
> 
> ---
> This SF.net email is sponsored by: SF.net Giveback Program.
> Does SourceForge.net help you be more productive?  Does it
> help you create better code?  SHARE THE LOVE, and help us help
> YOU!  Click Here: http://sourceforge.net/donate/
> ___
> hibernate-devel mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/hibernate-devel



---
This SF.net email is sponsored by: SF.net Giveback Program.
Does SourceForge.net help you be more productive?  Does it
help you create better code?  SHARE THE LOVE, and help us help
YOU!  Click Here: http://sourceforge.net/donate/
___
hibernate-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/hibernate-devel


Re: [Hibernate] Query Counter Interceptor?

2003-11-24 Thread Thomas Bentzen
Eric Pugh wrote:

Hi all,

I am doing some performance tuning on my Hibernate based app.  I noticed
that a lot of my HQL is quite unoptimized, and requires many hits to the
database.  So I am using a combination of JunitPerf to monitor how long a
unit test takes and the show_sql to look at the number of SQL statements.
Which makes me wonder, has anyone written an interceptor that counts
individual queries to the database?  Basically I am looking for something
that reports back the number of queries by table:
Table   #   Type
Customer10  inserts
Customer, Workorder 5   selects
Status, Workorder   15  selects
Status  5   deletes
That way, I could then see if my tunings are helping.  I know the overall
count of selects isn't the perfect way to measure performance, but it is a
good gross indicator of performance.
Eric



 

Hi Eric

You could fairly easy write an aspect to do exctly that. Thanks to the 
nicely written codebase in Hibernate is this pretty straitforward to do.

Cheers
Thomas Bentzen


---
This SF.net email is sponsored by: SF.net Giveback Program.
Does SourceForge.net help you be more productive?  Does it
help you create better code?  SHARE THE LOVE, and help us help
YOU!  Click Here: http://sourceforge.net/donate/
___
hibernate-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/hibernate-devel