Hallo
Inhalt der Datenbank:
Tabelle "Teams":
TEAM_ID 4
NAME: team1
PLAYED_GAMES 0
Tabelle "Team_Members":
TEAM_ID 4
MEMBER_ID 5
---
TEAM_ID 4
MEMBER_ID 10
Tabelle "Members":
MEMBER_ID 5
EMAIL
member2@hotmilk.ch
USERNAME member2
---
MEMBER_ID 10
EMAIL
member4@hotmilk.ch
USERNAME member4
Der code sieht folgendermassen aus:
Code:
public T findById(ID id, boolean lock) {
T entity;
if (lock) {
entity = (T) getSession().load(getPersistentClass(), id,
LockMode.UPGRADE);
} else {
entity = (T) getSession().load(getPersistentClass(), id);
}
return entity;
}
Der Code geht ins else, getPersistentClass() gibt "ch.hotmilk.jadezu.model.Team" zurueck. Bei der ID uebergebe ich 4L.
Hier wird nur die Klasse Team instanziert. Wenn ich dananch team.getMembers() aufrufe:
Code:
Hibernate:
select
team0_.TEAM_ID as TEAM1_1_0_,
team0_.NAME as NAME1_0_,
team0_.PLAYED_GAMES as PLAYED3_1_0_
from
TEAMS team0_
where
team0_.TEAM_ID=?
Jan 27, 2009 5:45:43 PM ch.hotmilk.jadezu.model.Team <init>
INFO: Class instaniated
Hibernate:
select
members0_.TEAM_ID as TEAM1_1_,
members0_.MEMBER_ID as MEMBER2_1_,
member1_.MEMBER_ID as MEMBER1_0_0_,
member1_.EMAIL as EMAIL0_0_,
member1_.LASTNAME as LASTNAME0_0_,
member1_.SURNAME as SURNAME0_0_,
member1_.USERNAME as USERNAME0_0_,
member1_.PASSWORD as PASSWORD0_0_,
member1_.HOME_ADRESS as HOME7_0_0_,
member1_.IS_ADMIN as IS8_0_0_,
member1_.IS_SYS_ADMIN as IS9_0_0_
from
TEAM_MEMBERS members0_
left outer join
MEMBERS member1_
on members0_.MEMBER_ID=member1_.MEMBER_ID
where
members0_.TEAM_ID=?
Die Member Collection in der Klasse Team ist nicht "null", sondern leer, es hat einfach keine Objekte drin.
Vielen Dank schon mal fuer deine Muehe.
gruess
stephan