I'm having a show stopper issue with Roo/Spring/Tiles that I really hope someone can help me get past.
When I use the clinic.roo script with a minor change to accommodate security/user roles I am running into a Hibernate performance problem.
Recipe to reproduce with Roo 1.2.1.
Here is the slightly modified clinic script.
Add the following properties to the persistence.xml file to view the Hibernate SQL in the log.Code:project --topLevelPackage com.springsource.petclinic jpa setup --provider HIBERNATE --database HYPERSONIC_IN_MEMORY enum type --class ~.reference.PetType enum constant --name Dog enum constant --name Cat enum constant --name Bird enum type --class ~.reference.Specialty enum constant --name Cardiology enum constant --name Dentistry enum constant --name Nutrition entity jpa --class ~.domain.Pet --sequenceName PET_SEQ entity jpa --class ~.domain.Visit --sequenceName VISIT_SEQ entity jpa --class ~.domain.AbstractPerson --abstract entity jpa --class ~.domain.Vet --extends ~.domain.AbstractPerson entity jpa --class ~.domain.Owner --extends ~.domain.AbstractPerson entity jpa --class ~.domain.Auth field string --fieldName firstName --sizeMin 3 --sizeMax 30 --class ~.domain.AbstractPerson field string --fieldName lastName --notNull --sizeMin 3 --sizeMax 30 field string --fieldName address --notNull --sizeMax 50 --sizeMin 1 field string --fieldName city --notNull --sizeMax 30 field string --fieldName telephone --notNull field string --fieldName homePage --sizeMax 30 field string --fieldName email --sizeMax 30 --sizeMin 6 field date --fieldName birthDay --type java.util.Date --notNull field string --fieldName description --sizeMax 255 --class ~.domain.Visit field date --fieldName visitDate --type java.util.Date --notNull --past field reference --fieldName pet --type ~.domain.Pet --notNull field reference --fieldName vet --type ~.domain.Vet field boolean --fieldName sendReminders --notNull --primitive --class ~.domain.Pet field string --fieldName name --notNull --sizeMin 1 field number --fieldName weight --type java.lang.Float --notNull --min 0 field reference --fieldName owner --type ~.domain.Owner field enum --fieldName type --type ~.reference.PetType --notNull field date --fieldName employedSince --type java.util.Calendar --notNull --past --class ~.domain.Vet field enum --fieldName specialty --type ~.reference.Specialty --notNull false field string --fieldName name --class ~.domain.Auth field set --fieldName owners --type ~.domain.Owner --cardinality MANY_TO_MANY --fetch LAZY field set --class ~.domain.Owner --fieldName pets --type ~.domain.Pet --mappedBy owner --notNull false --cardinality ONE_TO_MANY field set --fieldName roles --type ~.domain.Auth --cardinality MANY_TO_MANY --fetch LAZY --mappedBy "owners" finder add --finderName findPetsByNameAndWeight --class ~.domain.Pet finder add --finderName findPetsByOwner finder add --finderName findPetsBySendRemindersAndWeightLessThan finder add --finderName findPetsByTypeAndNameLike finder add --finderName findVisitsByDescriptionAndVisitDate --class ~.domain.Visit finder add --finderName findVisitsByVisitDateBetween finder add --finderName findVisitsByDescriptionLike web mvc setup web mvc all --package ~.web web mvc finder all
Run the server -Code:<property name="hibernate.show_sql" value="true"/> <property name="hibernate.format_sql" value="true"/>
PROBLEM: If you create an Auth object and a couple Owners with a couple Pets when you view one Pet with /pets/1 you can see in the System Log that there will be lots of SQL that query the curricular references and load the full Database. I have all the related entities as FetchType.LAZY but they are still loaded even though they are not being shown on the page.Code:mvn jetty:run
When stepping through the debugger it seems that somewhere in JspTilesRequestContext is touching every property in the Hibernate Entity and causing recursive requests.Code:Hibernate: select pet0_.id as id3_1_, pet0_.name as name3_1_, pet0_.owner as owner3_1_, pet0_.send_reminders as send3_3_1_, pet0_.type as type3_1_, pet0_.version as version3_1_, pet0_.weight as weight3_1_, owner1_.id as id0_0_, owner1_.address as address0_0_, owner1_.birth_day as birth4_0_0_, owner1_.city as city0_0_, owner1_.email as email0_0_, owner1_.first_name as first7_0_0_, owner1_.home_page as home8_0_0_, owner1_.last_name as last9_0_0_, owner1_.telephone as telephone0_0_, owner1_.version as version0_0_ from pet pet0_ left outer join abstract_person owner1_ on pet0_.owner=owner1_.id where pet0_.id=? Hibernate: select pets0_.owner as owner0_1_, pets0_.id as id1_, pets0_.id as id3_0_, pets0_.name as name3_0_, pets0_.owner as owner3_0_, pets0_.send_reminders as send3_3_0_, pets0_.type as type3_0_, pets0_.version as version3_0_, pets0_.weight as weight3_0_ from pet pets0_ where pets0_.owner=? Hibernate: select roles0_.owners as owners0_1_, roles0_.roles as roles1_, auth1_.id as id1_0_, auth1_.name as name1_0_, auth1_.version as version1_0_ from auth_owners roles0_ inner join auth auth1_ on roles0_.roles=auth1_.id where roles0_.owners=? Hibernate: select owners0_.roles as roles1_1_, owners0_.owners as owners1_, owner1_.id as id0_0_, owner1_.address as address0_0_, owner1_.birth_day as birth4_0_0_, owner1_.city as city0_0_, owner1_.email as email0_0_, owner1_.first_name as first7_0_0_, owner1_.home_page as home8_0_0_, owner1_.last_name as last9_0_0_, owner1_.telephone as telephone0_0_, owner1_.version as version0_0_ from auth_owners owners0_ inner join abstract_person owner1_ on owners0_.owners=owner1_.id where owners0_.roles=? Hibernate: select pets0_.owner as owner0_1_, pets0_.id as id1_, pets0_.id as id3_0_, pets0_.name as name3_0_, pets0_.owner as owner3_0_, pets0_.send_reminders as send3_3_0_, pets0_.type as type3_0_, pets0_.version as version3_0_, pets0_.weight as weight3_0_ from pet pets0_ where pets0_.owner=? Hibernate: select roles0_.owners as owners0_1_, roles0_.roles as roles1_, auth1_.id as id1_0_, auth1_.name as name1_0_, auth1_.version as version1_0_ from auth_owners roles0_ inner join auth auth1_ on roles0_.roles=auth1_.id where roles0_.owners=?
Please help. Thanks,
Ben


Reply With Quote
