2012-07-20 67 views
0

我有一個應用程序可以很好地與玻璃魚Eclipselink工作。因爲它在就業市場上的要求非常之多,所以我試圖移植應用程序以在Glassfish 3.1.2上使用Hibernate 4.1.5.Final。我所有的實體類都使用註釋,而我沒有映射文件。端口從玻璃魚eclipselink休眠EntityNotFoundException - 但目前在db

我設置了Maven依賴,並在persistence.xml中創建一個新的Hibernate持久性基礎單位:

<persistence-unit name="testHibernate" transaction-type="JTA"> 
    <provider>org.hibernate.ejb.HibernatePersistence</provider> 
    <jta-data-source>jdbc/myco</jta-data-source> 
    <exclude-unlisted-classes>false</exclude-unlisted-classes> 
    <properties> 
     <property name="hibernate.hbm2ddl.auto" value="validate"/> 
     <property name="hibernate.archive.autodetection" value="class, hbm"/> 
     <property name="hibernate.show_sql" value="true"/> 
     <property name="hibernate.format_sql" value="true"/> 
     <property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.SunONETransactionManagerLookup"/> 
     <property name="hibernate.dialect" value="uk.co.myco.general.Mysql5BitBooleanDialect"/> 
     <property name="hibernate.generate_statistics" value="true"/> 
    </properties> 
    </persistence-unit> 

在下面的查詢記錄後執行:

@PersistenceContext(unitName = "testHibernate") 
protected EntityManager em; 
... 
Query query = em.createQuery("SELECT u FROM User u WHERE u.userName = ?1"); 
query.setParameter(1, "testuser"); 
User user = (User) query.getSingleResult(); 

,這將引發的javax。 persistence.EntityNotFoundException:無法找到id爲1的uk.co.myco.entities.Player。Player類參照 這樣的User類:

@OneToOne 
@JoinColumn(name = "defaultPlayer", referencedColumnName = "id") 
private Player defaultPlayer; 

「Player」實體是持久繼承層次結構的一部分,並且從基類繼承的所有其他實體似乎都包含在查詢中。

與ID爲1的球員存在,肯定在數據庫中,但是這是瘋狂 複雜的查詢,這似乎是執行,有沒有人有如何查詢 可以通過簡單而產生的任何想法從用戶選擇U U如上所示?

select 
     player0_.id as id0_13_, 
     player0_1_.createUser as createUser0_13_, 
     player0_1_.created as created0_13_, 
     player0_1_.entityState as entitySt3_0_13_, 
     player0_1_.updateUser as updateUser0_13_, 
     player0_1_.updated as updated0_13_, 
     player0_1_.version as version0_13_, 
     player0_1_.ageGroup as ageGroup0_13_, 
     player0_1_.ageGroupNickname as ageGroup7_0_13_, 
     player0_1_.country as country0_13_, 
     player0_1_.currentSeason as current16_0_13_, 
     player0_1_.dtype as dtype0_13_, 
     player0_1_.introNotes as introNotes0_13_, 
     player0_1_.mainLocation as mainLoc17_0_13_, 
     player0_1_.name as name0_13_, 
     player0_1_.photoId as photoId0_13_, 
     player0_1_.sport as sport0_13_, 
     player0_.birthCertificate as birthCer1_1_13_, 
     player0_.defaultPlayer as defaultP2_1_13_, 
     player0_.dob as dob1_13_, 
     player0_.email as email1_13_, 
     player0_.firstName as firstName1_13_, 
     player0_.lastName as lastName1_13_, 
     player0_.middleInitial as middleIn7_1_13_, 
     player0_.photo as photo1_13_, 
     player0_.user as user1_13_, 
     user1_.id as id6_0_, 
     user1_.createUser as createUser6_0_, 
     user1_.created as created6_0_, 
     user1_.entityState as entitySt3_6_0_, 
     user1_.updateUser as updateUser6_0_, 
     user1_.updated as updated6_0_, 
     user1_.version as version6_0_, 
     user1_.agreedTerms as agreedTe6_6_0_, 
     user1_.browserType as browserT7_6_0_, 
     user1_.country as country6_0_, 
     user1_.dateFormat as dateFormat6_0_, 
     user1_.defaultPlayer as default45_6_0_, 
     user1_.dob as dob6_0_, 
     user1_.email as email6_0_, 
     user1_.emailVerified as emailVe12_6_0_, 
     user1_.firstName as firstName6_0_, 
     user1_.gender as gender6_0_, 
     user1_.groupName as groupName6_0_, 
     user1_.addrCountry as addrCou16_6_0_, 
     user1_.addrCounty as addrCounty6_0_, 
     user1_.addrGeoStatus as addrGeo18_6_0_, 
     user1_.addrLat as addrLat6_0_, 
     user1_.addrLine1 as addrLine20_6_0_, 
     user1_.addrLine2 as addrLine21_6_0_, 
     user1_.addrLng as addrLng6_0_, 
     user1_.addrPostCode as addrPos23_6_0_, 
     user1_.addrTownCity as addrTow24_6_0_, 
     user1_.lastLoginFailureIpAddress as lastLog25_6_0_, 
     user1_.lastLoginIpAddress as lastLog26_6_0_, 
     user1_.lastLoginTime as lastLog27_6_0_, 
     user1_.lastName as lastName6_0_, 
     user1_.loginCount as loginCount6_0_, 
     user1_.loginFailures as loginFa30_6_0_, 
     user1_.middleInitial as middleI31_6_0_, 
     user1_.mobileSecurityCode as mobileS32_6_0_, 
     user1_.mobileVerified as mobileV33_6_0_, 
     user1_.passWord as passWord6_0_, 
     user1_.phoneHome as phoneHome6_0_, 
     user1_.phoneMobile as phoneMo36_6_0_, 
     user1_.regRandomNumber as regRand37_6_0_, 
     user1_.registrationIpAddress as registr38_6_0_, 
     user1_.timeZone as timeZone6_0_, 
     user1_.timeZoneGroup as timeZon40_6_0_, 
     user1_.userAdmin as userAdmin6_0_, 
     user1_.userName as userName6_0_, 
     user2_.id as id6_1_, 
     user2_.createUser as createUser6_1_, 
     user2_.created as created6_1_, 
     user2_.entityState as entitySt3_6_1_, 
     user2_.updateUser as updateUser6_1_, 
     user2_.updated as updated6_1_, 
     user2_.version as version6_1_, 
     user2_.agreedTerms as agreedTe6_6_1_, 
     user2_.browserType as browserT7_6_1_, 
     user2_.country as country6_1_, 
     user2_.dateFormat as dateFormat6_1_, 
     user2_.defaultPlayer as default45_6_1_, 
     user2_.dob as dob6_1_, 
     user2_.email as email6_1_, 
     user2_.emailVerified as emailVe12_6_1_, 
     user2_.firstName as firstName6_1_, 
     user2_.gender as gender6_1_, 
     user2_.groupName as groupName6_1_, 
     user2_.addrCountry as addrCou16_6_1_, 
     user2_.addrCounty as addrCounty6_1_, 
     user2_.addrGeoStatus as addrGeo18_6_1_, 
     user2_.addrLat as addrLat6_1_, 
     user2_.addrLine1 as addrLine20_6_1_, 
     user2_.addrLine2 as addrLine21_6_1_, 
     user2_.addrLng as addrLng6_1_, 
     user2_.addrPostCode as addrPos23_6_1_, 
     user2_.addrTownCity as addrTow24_6_1_, 
     user2_.lastLoginFailureIpAddress as lastLog25_6_1_, 
     user2_.lastLoginIpAddress as lastLog26_6_1_, 
     user2_.lastLoginTime as lastLog27_6_1_, 
     user2_.lastName as lastName6_1_, 
     user2_.loginCount as loginCount6_1_, 
     user2_.loginFailures as loginFa30_6_1_, 
     user2_.middleInitial as middleI31_6_1_, 
     user2_.mobileSecurityCode as mobileS32_6_1_, 
     user2_.mobileVerified as mobileV33_6_1_, 
     user2_.passWord as passWord6_1_, 
     user2_.phoneHome as phoneHome6_1_, 
     user2_.phoneMobile as phoneMo36_6_1_, 
     user2_.regRandomNumber as regRand37_6_1_, 
     user2_.registrationIpAddress as registr38_6_1_, 
     user2_.timeZone as timeZone6_1_, 
     user2_.timeZoneGroup as timeZon40_6_1_, 
     user2_.userAdmin as userAdmin6_1_, 
     user2_.userName as userName6_1_, 
     user3_.id as id6_2_, 
     user3_.createUser as createUser6_2_, 
     user3_.created as created6_2_, 
     user3_.entityState as entitySt3_6_2_, 
     user3_.updateUser as updateUser6_2_, 
     user3_.updated as updated6_2_, 
     user3_.version as version6_2_, 
     user3_.agreedTerms as agreedTe6_6_2_, 
     user3_.browserType as browserT7_6_2_, 
     user3_.country as country6_2_, 
     user3_.dateFormat as dateFormat6_2_, 
     user3_.defaultPlayer as default45_6_2_, 
     user3_.dob as dob6_2_, 
     user3_.email as email6_2_, 
     user3_.emailVerified as emailVe12_6_2_, 
     user3_.firstName as firstName6_2_, 
     user3_.gender as gender6_2_, 
     user3_.groupName as groupName6_2_, 
     user3_.addrCountry as addrCou16_6_2_, 
     user3_.addrCounty as addrCounty6_2_, 
     user3_.addrGeoStatus as addrGeo18_6_2_, 
     user3_.addrLat as addrLat6_2_, 
     user3_.addrLine1 as addrLine20_6_2_, 
     user3_.addrLine2 as addrLine21_6_2_, 
     user3_.addrLng as addrLng6_2_, 
     user3_.addrPostCode as addrPos23_6_2_, 
     user3_.addrTownCity as addrTow24_6_2_, 
     user3_.lastLoginFailureIpAddress as lastLog25_6_2_, 
     user3_.lastLoginIpAddress as lastLog26_6_2_, 
     user3_.lastLoginTime as lastLog27_6_2_, 
     user3_.lastName as lastName6_2_, 
     user3_.loginCount as loginCount6_2_, 
     user3_.loginFailures as loginFa30_6_2_, 
     user3_.middleInitial as middleI31_6_2_, 
     user3_.mobileSecurityCode as mobileS32_6_2_, 
     user3_.mobileVerified as mobileV33_6_2_, 
     user3_.passWord as passWord6_2_, 
     user3_.phoneHome as phoneHome6_2_, 
     user3_.phoneMobile as phoneMo36_6_2_, 
     user3_.regRandomNumber as regRand37_6_2_, 
     user3_.registrationIpAddress as registr38_6_2_, 
     user3_.timeZone as timeZone6_2_, 
     user3_.timeZoneGroup as timeZon40_6_2_, 
     user3_.userAdmin as userAdmin6_2_, 
     user3_.userName as userName6_2_, 
     player4_.id as id0_3_, 
     player4_1_.createUser as createUser0_3_, 
     player4_1_.created as created0_3_, 
     player4_1_.entityState as entitySt3_0_3_, 
     player4_1_.updateUser as updateUser0_3_, 
     player4_1_.updated as updated0_3_, 
     player4_1_.version as version0_3_, 
     player4_1_.ageGroup as ageGroup0_3_, 
     player4_1_.ageGroupNickname as ageGroup7_0_3_, 
     player4_1_.country as country0_3_, 
     player4_1_.currentSeason as current16_0_3_, 
     player4_1_.dtype as dtype0_3_, 
     player4_1_.introNotes as introNotes0_3_, 
     player4_1_.mainLocation as mainLoc17_0_3_, 
     player4_1_.name as name0_3_, 
     player4_1_.photoId as photoId0_3_, 
     player4_1_.sport as sport0_3_, 
     player4_.birthCertificate as birthCer1_1_3_, 
     player4_.defaultPlayer as defaultP2_1_3_, 
     player4_.dob as dob1_3_, 
     player4_.email as email1_3_, 
     player4_.firstName as firstName1_3_, 
     player4_.lastName as lastName1_3_, 
     player4_.middleInitial as middleIn7_1_3_, 
     player4_.photo as photo1_3_, 
     player4_.user as user1_3_, 
     user5_.id as id6_4_, 
     user5_.createUser as createUser6_4_, 
     user5_.created as created6_4_, 
     user5_.entityState as entitySt3_6_4_, 
     user5_.updateUser as updateUser6_4_, 
     user5_.updated as updated6_4_, 
     user5_.version as version6_4_, 
     user5_.agreedTerms as agreedTe6_6_4_, 
     user5_.browserType as browserT7_6_4_, 
     user5_.country as country6_4_, 
     user5_.dateFormat as dateFormat6_4_, 
     user5_.defaultPlayer as default45_6_4_, 
     user5_.dob as dob6_4_, 
     user5_.email as email6_4_, 
     user5_.emailVerified as emailVe12_6_4_, 
     user5_.firstName as firstName6_4_, 
     user5_.gender as gender6_4_, 
     user5_.groupName as groupName6_4_, 
     user5_.addrCountry as addrCou16_6_4_, 
     user5_.addrCounty as addrCounty6_4_, 
     user5_.addrGeoStatus as addrGeo18_6_4_, 
     user5_.addrLat as addrLat6_4_, 
     user5_.addrLine1 as addrLine20_6_4_, 
     user5_.addrLine2 as addrLine21_6_4_, 
     user5_.addrLng as addrLng6_4_, 
     user5_.addrPostCode as addrPos23_6_4_, 
     user5_.addrTownCity as addrTow24_6_4_, 
     user5_.lastLoginFailureIpAddress as lastLog25_6_4_, 
     user5_.lastLoginIpAddress as lastLog26_6_4_, 
     user5_.lastLoginTime as lastLog27_6_4_, 
     user5_.lastName as lastName6_4_, 
     user5_.loginCount as loginCount6_4_, 
     user5_.loginFailures as loginFa30_6_4_, 
     user5_.middleInitial as middleI31_6_4_, 
     user5_.mobileSecurityCode as mobileS32_6_4_, 
     user5_.mobileVerified as mobileV33_6_4_, 
     user5_.passWord as passWord6_4_, 
     user5_.phoneHome as phoneHome6_4_, 
     user5_.phoneMobile as phoneMo36_6_4_, 
     user5_.regRandomNumber as regRand37_6_4_, 
     user5_.registrationIpAddress as registr38_6_4_, 
     user5_.timeZone as timeZone6_4_, 
     user5_.timeZoneGroup as timeZon40_6_4_, 
     user5_.userAdmin as userAdmin6_4_, 
     user5_.userName as userName6_4_, 
     season6_.id as id2_5_, 
     season6_.createUser as createUser2_5_, 
     season6_.created as created2_5_, 
     season6_.entityState as entitySt3_2_5_, 
     season6_.updateUser as updateUser2_5_, 
     season6_.updated as updated2_5_, 
     season6_.version as version2_5_, 
     season6_.arriveBeforeMins as arriveBe6_2_5_, 
     season6_.earliestHours as earliest7_2_5_, 
     season6_.earliestMins as earliest8_2_5_, 
     season6_.encodedDaysOfWeek as encodedD9_2_5_, 
     season6_.endDate as endDate2_5_, 
     season6_.extraTime as extraTime2_5_, 
     season6_.latestHours as latestH12_2_5_, 
     season6_.latestMins as latestMins2_5_, 
     season6_.league as league2_5_, 
     season6_.matchDuration as matchDu14_2_5_, 
     season6_.season as season2_5_, 
     season6_.startDate as startDate2_5_, 
     user7_.id as id6_6_, 
     user7_.createUser as createUser6_6_, 
     user7_.created as created6_6_, 
     user7_.entityState as entitySt3_6_6_, 
     user7_.updateUser as updateUser6_6_, 
     user7_.updated as updated6_6_, 
     user7_.version as version6_6_, 
     user7_.agreedTerms as agreedTe6_6_6_, 
     user7_.browserType as browserT7_6_6_, 
     user7_.country as country6_6_, 
     user7_.dateFormat as dateFormat6_6_, 
     user7_.defaultPlayer as default45_6_6_, 
     user7_.dob as dob6_6_, 
     user7_.email as email6_6_, 
     user7_.emailVerified as emailVe12_6_6_, 
     user7_.firstName as firstName6_6_, 
     user7_.gender as gender6_6_, 
     user7_.groupName as groupName6_6_, 
     user7_.addrCountry as addrCou16_6_6_, 
     user7_.addrCounty as addrCounty6_6_, 
     user7_.addrGeoStatus as addrGeo18_6_6_, 
     user7_.addrLat as addrLat6_6_, 
     user7_.addrLine1 as addrLine20_6_6_, 
     user7_.addrLine2 as addrLine21_6_6_, 
     user7_.addrLng as addrLng6_6_, 
     user7_.addrPostCode as addrPos23_6_6_, 
     user7_.addrTownCity as addrTow24_6_6_, 
     user7_.lastLoginFailureIpAddress as lastLog25_6_6_, 
     user7_.lastLoginIpAddress as lastLog26_6_6_, 
     user7_.lastLoginTime as lastLog27_6_6_, 
     user7_.lastName as lastName6_6_, 
     user7_.loginCount as loginCount6_6_, 
     user7_.loginFailures as loginFa30_6_6_, 
     user7_.middleInitial as middleI31_6_6_, 
     user7_.mobileSecurityCode as mobileS32_6_6_, 
     user7_.mobileVerified as mobileV33_6_6_, 
     user7_.passWord as passWord6_6_, 
     user7_.phoneHome as phoneHome6_6_, 
     user7_.phoneMobile as phoneMo36_6_6_, 
     user7_.regRandomNumber as regRand37_6_6_, 
     user7_.registrationIpAddress as registr38_6_6_, 
     user7_.timeZone as timeZone6_6_, 
     user7_.timeZoneGroup as timeZon40_6_6_, 
     user7_.userAdmin as userAdmin6_6_, 
     user7_.userName as userName6_6_, 
     user8_.id as id6_7_, 
     user8_.createUser as createUser6_7_, 
     user8_.created as created6_7_, 
     user8_.entityState as entitySt3_6_7_, 
     user8_.updateUser as updateUser6_7_, 
     user8_.updated as updated6_7_, 
     user8_.version as version6_7_, 
     user8_.agreedTerms as agreedTe6_6_7_, 
     user8_.browserType as browserT7_6_7_, 
     user8_.country as country6_7_, 
     user8_.dateFormat as dateFormat6_7_, 
     user8_.defaultPlayer as default45_6_7_, 
     user8_.dob as dob6_7_, 
     user8_.email as email6_7_, 
     user8_.emailVerified as emailVe12_6_7_, 
     user8_.firstName as firstName6_7_, 
     user8_.gender as gender6_7_, 
     user8_.groupName as groupName6_7_, 
     user8_.addrCountry as addrCou16_6_7_, 
     user8_.addrCounty as addrCounty6_7_, 
     user8_.addrGeoStatus as addrGeo18_6_7_, 
     user8_.addrLat as addrLat6_7_, 
     user8_.addrLine1 as addrLine20_6_7_, 
     user8_.addrLine2 as addrLine21_6_7_, 
     user8_.addrLng as addrLng6_7_, 
     user8_.addrPostCode as addrPos23_6_7_, 
     user8_.addrTownCity as addrTow24_6_7_, 
     user8_.lastLoginFailureIpAddress as lastLog25_6_7_, 
     user8_.lastLoginIpAddress as lastLog26_6_7_, 
     user8_.lastLoginTime as lastLog27_6_7_, 
     user8_.lastName as lastName6_7_, 
     user8_.loginCount as loginCount6_7_, 
     user8_.loginFailures as loginFa30_6_7_, 
     user8_.middleInitial as middleI31_6_7_, 
     user8_.mobileSecurityCode as mobileS32_6_7_, 
     user8_.mobileVerified as mobileV33_6_7_, 
     user8_.passWord as passWord6_7_, 
     user8_.phoneHome as phoneHome6_7_, 
     user8_.phoneMobile as phoneMo36_6_7_, 
     user8_.regRandomNumber as regRand37_6_7_, 
     user8_.registrationIpAddress as registr38_6_7_, 
     user8_.timeZone as timeZone6_7_, 
     user8_.timeZoneGroup as timeZon40_6_7_, 
     user8_.userAdmin as userAdmin6_7_, 
     user8_.userName as userName6_7_, 
     league9_.id as id0_8_, 
     league9_1_.createUser as createUser0_8_, 
     league9_1_.created as created0_8_, 
     league9_1_.entityState as entitySt3_0_8_, 
     league9_1_.updateUser as updateUser0_8_, 
     league9_1_.updated as updated0_8_, 
     league9_1_.version as version0_8_, 
     league9_1_.ageGroup as ageGroup0_8_, 
     league9_1_.ageGroupNickname as ageGroup7_0_8_, 
     league9_1_.country as country0_8_, 
     league9_1_.currentSeason as current16_0_8_, 
     league9_1_.dtype as dtype0_8_, 
     league9_1_.introNotes as introNotes0_8_, 
     league9_1_.mainLocation as mainLoc17_0_8_, 
     league9_1_.name as name0_8_, 
     league9_1_.photoId as photoId0_8_, 
     league9_1_.sport as sport0_8_, 
     league9_.leagueGroup as leagueGr6_25_8_, 
     league9_.leagueTable as leagueTa7_25_8_, 
     league9_.pointsDraw as pointsDraw25_8_, 
     league9_.pointsLoss as pointsLoss25_8_, 
     league9_.pointsWin as pointsWin25_8_, 
     league9_.splitter as splitter25_8_, 
     location10_.id as id0_9_, 
     location10_1_.createUser as createUser0_9_, 
     location10_1_.created as created0_9_, 
     location10_1_.entityState as entitySt3_0_9_, 
     location10_1_.updateUser as updateUser0_9_, 
     location10_1_.updated as updated0_9_, 
     location10_1_.version as version0_9_, 
     location10_1_.ageGroup as ageGroup0_9_, 
     location10_1_.ageGroupNickname as ageGroup7_0_9_, 
     location10_1_.country as country0_9_, 
     location10_1_.currentSeason as current16_0_9_, 
     location10_1_.dtype as dtype0_9_, 
     location10_1_.introNotes as introNotes0_9_, 
     location10_1_.mainLocation as mainLoc17_0_9_, 
     location10_1_.name as name0_9_, 
     location10_1_.photoId as photoId0_9_, 
     location10_1_.sport as sport0_9_, 
     location10_.addrCountry as addrCoun1_13_9_, 
     location10_.addrCounty as addrCounty13_9_, 
     location10_.addrGeoStatus as addrGeoS3_13_9_, 
     location10_.addrLat as addrLat13_9_, 
     location10_.addrLine1 as addrLine5_13_9_, 
     location10_.addrLine2 as addrLine6_13_9_, 
     location10_.addrLng as addrLng13_9_, 
     location10_.addrPostCode as addrPost8_13_9_, 
     location10_.addrTownCity as addrTown9_13_9_, 
     location10_.comments as comments13_9_, 
     location10_.entity as entity13_9_, 
     location10_.globalx as globalx13_9_, 
     location10_.locationType as locatio12_13_9_, 
     location10_.user as user13_9_, 
     superentit11_.id as id0_10_, 
     superentit11_.createUser as createUser0_10_, 
     superentit11_.created as created0_10_, 
     superentit11_.entityState as entitySt3_0_10_, 
     superentit11_.updateUser as updateUser0_10_, 
     superentit11_.updated as updated0_10_, 
     superentit11_.version as version0_10_, 
     superentit11_.ageGroup as ageGroup0_10_, 
     superentit11_.ageGroupNickname as ageGroup7_0_10_, 
     ... deleted due to over stackoverflow post limit ... 
     user12_.agreedTerms as agreedTe6_6_11_, 
     user12_.browserType as browserT7_6_11_, 
     user12_.country as country6_11_, 
     user12_.dateFormat as dateFormat6_11_, 
     user12_.defaultPlayer as default45_6_11_, 
     user12_.dob as dob6_11_, 
     user12_.email as email6_11_, 
     user12_.emailVerified as emailVe12_6_11_, 
     user12_.firstName as firstName6_11_, 
     user12_.gender as gender6_11_, 
     user12_.groupName as groupName6_11_, 
     user12_.addrCountry as addrCou16_6_11_, 
     user12_.addrCounty as addrCounty6_11_, 
     user12_.addrGeoStatus as addrGeo18_6_11_, 
     user12_.addrLat as addrLat6_11_, 
     user12_.addrLine1 as addrLine20_6_11_, 
     user12_.addrLine2 as addrLine21_6_11_, 
     user12_.addrLng as addrLng6_11_, 
     user12_.addrPostCode as addrPos23_6_11_, 
     user12_.addrTownCity as addrTow24_6_11_, 
     user12_.lastLoginFailureIpAddress as lastLog25_6_11_, 
     user12_.lastLoginIpAddress as lastLog26_6_11_, 
     user12_.lastLoginTime as lastLog27_6_11_, 
     user12_.lastName as lastName6_11_, 
     user12_.loginCount as loginCount6_11_, 
     user12_.loginFailures as loginFa30_6_11_, 
     user12_.middleInitial as middleI31_6_11_, 
     user12_.mobileSecurityCode as mobileS32_6_11_, 
     user12_.mobileVerified as mobileV33_6_11_, 
     user12_.passWord as passWord6_11_, 
     user12_.phoneHome as phoneHome6_11_, 
     user12_.phoneMobile as phoneMo36_6_11_, 
     user12_.regRandomNumber as regRand37_6_11_, 
     user12_.registrationIpAddress as registr38_6_11_, 
     user12_.timeZone as timeZone6_11_, 
     user12_.timeZoneGroup as timeZon40_6_11_, 
     user12_.userAdmin as userAdmin6_11_, 
     user12_.userName as userName6_11_, 
     user13_.id as id6_12_, 
     user13_.createUser as createUser6_12_, 
     user13_.created as created6_12_, 
     user13_.entityState as entitySt3_6_12_, 
     user13_.updateUser as updateUser6_12_, 
     user13_.updated as updated6_12_, 
     user13_.version as version6_12_, 
     user13_.agreedTerms as agreedTe6_6_12_, 
     user13_.browserType as browserT7_6_12_, 
     user13_.country as country6_12_, 
     user13_.dateFormat as dateFormat6_12_, 
     user13_.defaultPlayer as default45_6_12_, 
     user13_.dob as dob6_12_, 
     user13_.email as email6_12_, 
     user13_.emailVerified as emailVe12_6_12_, 
     user13_.firstName as firstName6_12_, 
     user13_.gender as gender6_12_, 
     user13_.groupName as groupName6_12_, 
     user13_.addrCountry as addrCou16_6_12_, 
     user13_.addrCounty as addrCounty6_12_, 
     user13_.addrGeoStatus as addrGeo18_6_12_, 
     user13_.addrLat as addrLat6_12_, 
     user13_.addrLine1 as addrLine20_6_12_, 
     user13_.addrLine2 as addrLine21_6_12_, 
     user13_.addrLng as addrLng6_12_, 
     user13_.addrPostCode as addrPos23_6_12_, 
     user13_.addrTownCity as addrTow24_6_12_, 
     user13_.lastLoginFailureIpAddress as lastLog25_6_12_, 
     user13_.lastLoginIpAddress as lastLog26_6_12_, 
     user13_.lastLoginTime as lastLog27_6_12_, 
     user13_.lastName as lastName6_12_, 
     user13_.loginCount as loginCount6_12_, 
     user13_.loginFailures as loginFa30_6_12_, 
     user13_.middleInitial as middleI31_6_12_, 
     user13_.mobileSecurityCode as mobileS32_6_12_, 
     user13_.mobileVerified as mobileV33_6_12_, 
     user13_.passWord as passWord6_12_, 
     user13_.phoneHome as phoneHome6_12_, 
     user13_.phoneMobile as phoneMo36_6_12_, 
     user13_.regRandomNumber as regRand37_6_12_, 
     user13_.registrationIpAddress as registr38_6_12_, 
     user13_.timeZone as timeZone6_12_, 
     user13_.timeZoneGroup as timeZon40_6_12_, 
     user13_.userAdmin as userAdmin6_12_, 
     user13_.userName as userName6_12_ 
    from 
     players player0_ 
    inner join 
     superentities player0_1_ 
      on player0_.id=player0_1_.id 
    inner join 
     users user1_ 
      on player0_1_.createUser=user1_.id 
    left outer join 
     users user2_ 
      on user1_.createUser=user2_.id 
    left outer join 
     users user3_ 
      on user1_.updateUser=user3_.id 
    left outer join 
     players player4_ 
      on user1_.defaultPlayer=player4_.id 
    left outer join 
     superentities player4_1_ 
      on player4_.id=player4_1_.id 
    inner join 
     users user5_ 
      on player0_1_.updateUser=user5_.id 
    left outer join 
     seasons season6_ 
      on player0_1_.currentSeason=season6_.id 
    left outer join 
     users user7_ 
      on season6_.createUser=user7_.id 
    left outer join 
     users user8_ 
      on season6_.updateUser=user8_.id 
    left outer join 
     leagues league9_ 
      on season6_.league=league9_.id 
    left outer join 
     superentities league9_1_ 
      on league9_.id=league9_1_.id 
    left outer join 
     locations location10_ 
      on player0_1_.mainLocation=location10_.id 
    left outer join 
     superentities location10_1_ 
      on location10_.id=location10_1_.id 
    left outer join 
     superentities superentit11_ 
      on location10_.entity=superentit11_.id 
    left outer join 
     players superentit11_1_ 
      on superentit11_.id=superentit11_1_.id 
    left outer join 
     clubs superentit11_2_ 
      on superentit11_.id=superentit11_2_.id 
    left outer join 
     squads superentit11_3_ 
      on superentit11_.id=superentit11_3_.id 
    left outer join 
     businesses superentit11_4_ 
      on superentit11_.id=superentit11_4_.id 
    left outer join 
     locations superentit11_5_ 
      on superentit11_.id=superentit11_5_.id 
    left outer join 
     resources superentit11_6_ 
      on superentit11_.id=superentit11_6_.id 
    left outer join 
     sportscentres superentit11_7_ 
      on superentit11_.id=superentit11_7_.id 
    left outer join 
     leagues superentit11_8_ 
      on superentit11_.id=superentit11_8_.id 
    left outer join 
     leaguegroups superentit11_9_ 
      on superentit11_.id=superentit11_9_.id 
    left outer join 
     teams superentit11_10_ 
      on superentit11_.id=superentit11_10_.id 
    left outer join 
     users user12_ 
      on location10_.user=user12_.id 
    inner join 
     users user13_ 
      on player0_.user=user13_.id 
    where 
     player0_.id=1 

回答

1

查詢似乎表明你有一大堆被映射爲急切加載OnetoOne或多對一協會(這是不幸的是,默認值)。所以Hibernate熱切地加載它們。

例如,它似乎是一個用戶引用另一個用戶,它引用了用戶等,並且此關聯不是延遲加載。

它似乎也是你的所有實體繼承自一個共同的超級實體。這可能是錯誤的:商業和玩家不是同一種實體,不應該在同一個實體層次結構中。 commen實體可能應該被MappedSuperclass替換。

+0

謝謝,我已經取得了一些進展。有一個MappedSuperClass,其中包含用於存儲創建和上次更新用戶的屬性,以及從eclipselink行爲更改爲急切加載的問題。 SuperEntity的作用是少於10個實體類(它們具有很多共同性)擴展這個繼承樹的根,然後我可以存儲對SuperEntity的引用並使用多態性。我不認爲我可以存儲對MappedSuperClass的引用,因爲沒有公共ID? – Oversteer 2012-07-21 16:45:27

+0

不,你不能。但是你真的有與任何一種超級實體相關的實體嗎?哪種用例? – 2012-07-21 16:50:25

+0

這個想法是,球隊,俱樂部和聯賽都有成員,經理和事件(以及更多)。現在它的工作方式是擁有兩個SuperEntity屬性的會員表可以處理一個球員是一個球隊的成員,或者一個球隊是一個俱樂部的成員,或者是一個聯盟成員的球隊。我知道它看起來不太好,但是在某種程度上,我認爲它爲我節省了一些代碼。但是超級球員表將會採取一些錘鍊,我意識到這一點,而且我認爲我現在可以處理更好的思維結構。 – Oversteer 2012-07-21 16:58:25