Here are some details on my issue that bjaminwiz also had. I've aged 10 years in one day trying to figure this out.
The Parent class join field Code:
@OneToMany()
@JoinColumn(name = "EMP_ID")
public Set<TeamMemberAuthLimits> getAuthLimits() {
return authLimits;
}
Child class fieldsCode:
@Id
@Column(name = "EMP_ID", updatable = false, unique = false)
public String getEmployeeId() {
return employeeId;
}
public void setEmployeeId(String empId) {
this.employeeId = empId;
}
@Column(name = "AUTH_LIMIT_TYPE", updatable = false)
public String getAuthLimitType() {
return authLimitType;
}
public void setAuthLimitType(String authLimitType) {
this.authLimitType = authLimitType;
}
@Column(name = "AUTH_LIMIT_AMOUNT", updatable = false)
public BigDecimal getAuthLimitAmt() {
return authLimitAmount;
}
public void setAuthLimitAmt(BigDecimal authLimitAmount) {
this.authLimitAmount = authLimitAmount;
}
SQL statement hibernated generated, which does return the correct data when I run against the database using a SQL tool:Code:
Hibernate: select authlimits0_.EMP_ID as EMP1_1_, authlimits0_.EMP_ID as EMP1_19_0_, authlimits0_.AUTH_LIMIT_AMOUNT as AUTH2_19_0_, authlimits0_.AUTH_LIMIT_TYPE as AUTH3_19_0_ from COMMON.T_TEAM_MEMBER_AUTH_LIMITS authlimits0_ where authlimits0_.EMP_ID=?
Trace ouputNotice the "
[TRACE] CollectionLoadContext: found loading collection bound to current result set processing; reading row"It appears that hibernate is only hydrating the first row, then it uses that same row to populate the rest??? WTF?
Code:
[2010-10-07 09:57:27,600] [TRACE] AbstractBatcher: preparing statement
[2010-10-07 09:57:27,616] [TRACE] StringType: binding '00000444197' to parameter: 1
[2010-10-07 09:57:28,678] [DEBUG] AbstractBatcher: about to open ResultSet (open ResultSets: 0, globally: 0)
[2010-10-07 09:57:28,678] [DEBUG] Loader: result set contains (possibly empty) collection: [com.wellsfargo.wmg.tpl.domain.user.TeamMember.authLimits#00000444197]
[2010-10-07 09:57:28,678] [TRACE] LoadContexts: constructing collection load context for result set [oracle.jdbc.driver.OracleResultSetImpl@1f8aad]
[2010-10-07 09:57:28,678] [TRACE] CollectionLoadContext: starting attempt to find loading collection [[com.wellsfargo.wmg.tpl.domain.user.TeamMember.authLimits#00000444197]]
[2010-10-07 09:57:28,678] [TRACE] LoadContexts: attempting to locate loading collection entry [CollectionKey[com.wellsfargo.wmg.tpl.domain.user.TeamMember.authLimits#00000444197]] in any result-set context
[2010-10-07 09:57:28,678] [TRACE] LoadContexts: collection [CollectionKey[com.wellsfargo.wmg.tpl.domain.user.TeamMember.authLimits#00000444197]] not located in load context
[2010-10-07 09:57:28,694] [TRACE] CollectionLoadContext: collection not yet initialized; initializing
[2010-10-07 09:57:28,694] [TRACE] Loader: processing result set
[2010-10-07 09:57:28,694] [DEBUG] Loader: result set row: 0
[2010-10-07 09:57:28,694] [TRACE] StringType: returning '00000444197' as column: EMP1_19_0_
[2010-10-07 09:57:28,694] [DEBUG] Loader: result row: EntityKey[com.wellsfargo.wmg.tmm.domain.TeamMemberAuthLimits#00000444197]
[2010-10-07 09:57:28,694] [TRACE] Loader: Initializing object from ResultSet: [com.wellsfargo.wmg.tmm.domain.TeamMemberAuthLimits#00000444197]
[2010-10-07 09:57:28,694] [TRACE] AbstractEntityPersister: Hydrating entity: [com.wellsfargo.wmg.tmm.domain.TeamMemberAuthLimits#00000444197]
[2010-10-07 09:57:29,256] [TRACE] BigDecimalType: returning '50000000' as column: AUTH2_19_0_
[2010-10-07 09:57:29,256] [TRACE] StringType: returning 'AUTH000248' as column: AUTH3_19_0_
[2010-10-07 09:57:29,256] [TRACE] StringType: returning '00000444197' as column: EMP1_1_
[2010-10-07 09:57:29,256] [DEBUG] Loader: found row of collection: [com.wellsfargo.wmg.tpl.domain.user.TeamMember.authLimits#00000444197]
[2010-10-07 09:57:29,256] [TRACE] CollectionLoadContext: starting attempt to find loading collection [[com.wellsfargo.wmg.tpl.domain.user.TeamMember.authLimits#00000444197]]
[2010-10-07 09:57:29,256] [TRACE] LoadContexts: attempting to locate loading collection entry [CollectionKey[com.wellsfargo.wmg.tpl.domain.user.TeamMember.authLimits#00000444197]] in any result-set context
[2010-10-07 09:57:29,256] [TRACE] LoadContexts: collection [CollectionKey[com.wellsfargo.wmg.tpl.domain.user.TeamMember.authLimits#00000444197]] located in load context
[2010-10-07 09:57:29,256] [TRACE] CollectionLoadContext: found loading collection bound to current result set processing; reading row
[2010-10-07 09:57:29,256] [TRACE] StringType: returning '00000444197' as column: EMP1_1_
[2010-10-07 09:57:29,256] [TRACE] DefaultLoadEventListener: loading entity: [com.wellsfargo.wmg.tmm.domain.TeamMemberAuthLimits#00000444197]
[2010-10-07 09:57:29,256] [TRACE] DefaultLoadEventListener: attempting to resolve: [com.wellsfargo.wmg.tmm.domain.TeamMemberAuthLimits#00000444197]
[2010-10-07 09:57:29,256] [TRACE] DefaultLoadEventListener: resolved object in session cache: [com.wellsfargo.wmg.tmm.domain.TeamMemberAuthLimits#00000444197]
[2010-10-07 09:57:29,256] [DEBUG] Loader: result set row: 1
[2010-10-07 09:57:29,256] [TRACE] StringType: returning '00000444197' as column: EMP1_19_0_
[2010-10-07 09:57:29,256] [DEBUG] Loader: result row: EntityKey[com.wellsfargo.wmg.tmm.domain.TeamMemberAuthLimits#00000444197]
[2010-10-07 09:57:29,256] [TRACE] StringType: returning '00000444197' as column: EMP1_1_
[2010-10-07 09:57:29,256] [DEBUG] Loader: found row of collection: [com.wellsfargo.wmg.tpl.domain.user.TeamMember.authLimits#00000444197]
[2010-10-07 09:57:29,256] [TRACE] CollectionLoadContext: starting attempt to find loading collection [[com.wellsfargo.wmg.tpl.domain.user.TeamMember.authLimits#00000444197]]
[2010-10-07 09:57:29,256] [TRACE] LoadContexts: attempting to locate loading collection entry [CollectionKey[com.wellsfargo.wmg.tpl.domain.user.TeamMember.authLimits#00000444197]] in any result-set context
[2010-10-07 09:57:29,256] [TRACE] LoadContexts: collection [CollectionKey[com.wellsfargo.wmg.tpl.domain.user.TeamMember.authLimits#00000444197]] located in load context
[2010-10-07 09:57:29,256] [TRACE] CollectionLoadContext: found loading collection bound to current result set processing; reading row
[2010-10-07 09:57:29,256] [TRACE] StringType: returning '00000444197' as column: EMP1_1_
[2010-10-07 09:57:29,256] [TRACE] DefaultLoadEventListener: loading entity: [com.wellsfargo.wmg.tmm.domain.TeamMemberAuthLimits#00000444197]
[2010-10-07 09:57:29,256] [TRACE] DefaultLoadEventListener: attempting to resolve: [com.wellsfargo.wmg.tmm.domain.TeamMemberAuthLimits#00000444197]
[2010-10-07 09:57:29,256] [TRACE] DefaultLoadEventListener: resolved object in session cache: [com.wellsfargo.wmg.tmm.domain.TeamMemberAuthLimits#00000444197]
[2010-10-07 09:57:29,256] [DEBUG] Loader: result set row: 2