hibernate reviewer : graphviz, hibernate cfg to review jbpm 5.2

Hibernate Reviewer

OK… you read my article “dont-get-caught-hibernating”
and now you are curious to test your mappings/annotations. Now, you have access to the tool in github!


for the moment 2 main features, from your hibernate configuration :

  • generate a report of “violations” : it’s embbedable as a junit. I hope to get it soon contribute to sonar violations 😉
  • generate a graphviz graph of your model

current rules :

 * AvoidIgnoreNotFoundMappingReviewRule
 * AvoidJoinMappingReviewRule
 * AvoidPropertyRefMappingReviewRule
 * BatchSizeMappingReviewRule
 * CachingMappingReviewRule
 * LazyLoadMappingReviewRule

Samples from hibernate reviewer

  • some basic entity mappings with violations (HibernateTest)
  • some coming from jbpm 5.2 (Jbpm5GraphTest)

    The Jbpm case

    Sample graph based on jbpm 5.2

    All red arrows shows the following violations :

    org.jbpm.task.Task	BatchSizeMappingReviewRule	BLOCKER	no batch size at class level
    org.jbpm.task.Task	BatchSizeMappingReviewRule	BLOCKER	no batch size at collection level :org.jbpm.task.Task.subjects

    By default, jbpm don’t specify batch-size at class or collection level. This leads select n+1 issues. Adjusting the batch-size to a value that fits your need can optimize it to a 2 select for n task returned.

    You can fix this by adjusting programmatically the batch-size on persistentClass or Collection :

    	private void fixBatchSize(Configuration cfg) {
    		Iterator persist = cfg.getClassMappings();
    		while (persist.hasNext()) {
    			PersistentClass persistentClass = persist.next();
    		Iterator colls = cfg.getCollectionMappings();
    		while (colls.hasNext()) {
    			org.hibernate.mapping.Collection  object = (org.hibernate.mapping.Collection) colls.next();

    1. #1 by Martin Van Aken (@martinvanaken) on April 23, 2012 - 4:32 pm

      Would it work on generic JPA code (non hibernate) ? It would help to use it in more contexts.

      • #2 by mestachs on April 23, 2012 - 5:49 pm

        the reviewer works on jpa and hbm… it’s based on Configuration API
        the sample for jbpm 5.2 is jpa annotation only.

        For other jpa implementation… I don’t know if they have the same drawback as hibernate and so if the same rules apply.
        I don’t know either if jpa already define a meta-api like Configuration and Mapping on entityManager.
        For example does google app engine handle batch-size with a pretty good default ?

    2. #3 by mestachs on July 11, 2012 - 4:02 pm

      for people looking for another tool : http://tomaszdziurko.pl/2012/07/hibernate-smoke-detector/

    Leave a Reply

    Fill in your details below or click an icon to log in:

    WordPress.com Logo

    You are commenting using your WordPress.com account. Log Out /  Change )

    Google+ photo

    You are commenting using your Google+ account. Log Out /  Change )

    Twitter picture

    You are commenting using your Twitter account. Log Out /  Change )

    Facebook photo

    You are commenting using your Facebook account. Log Out /  Change )


    Connecting to %s

    %d bloggers like this: