hi, i have a simple ManyToMany relation between profile and and roles. there are 3 tables: profile(id, name), profile_role(profile_id, role_id) and role(id, name) and following mapping:
@Entity @Table(name = "profile") @SequenceGenerator(name = "PROFILE_SEQ", sequenceName = "profile_id_seq") class Profile { @ManyToMany(cascade = { CascadeType.PERSIST, CascadeType.MERGE }, fetch = FetchType.LAZY) @Cascade({ org.hibernate.annotations.CascadeType.SAVE_UPDATE }) @JoinTable(name = "profile_role", joinColumns = @JoinColumn(name = "profile_id"), inverseJoinColumns = @JoinColumn(name = "role_id")) @Sort(type = SortType.COMPARATOR, comparator = Role.class) public SortedSet<Role> getRoles() } here is resulting query: select PR.profile_id, PR.role_id, R.id, R.name from profile_role PR left outer join role R on PR.role_id=R.id where PR.profile_id=? it works perfect. well almost, i have just checked session size using MessAdmin tool and something strange appeared. Profile object is 13 MB having only one role inside! Hibernate version is 3.2.2GA. Moreover previously i was using xdoclet for mappings and above getRoles() property was mapped like this: /** * @hibernate.set table="profile_role" cascade="save-update" lazy="true" * @hibernate.collection-key column="profile_id" * @hibernate.collection-many-to-many class="org.model.domain.Role" column="role_id" */ public Set<Role> getRoles() which resulted in following queries: select RP.profile_id, RP.role_id from profile_role RP where RP.profile_id=? select R.id, R.name from role R where R.id=? so previous query has been splitted into 2 separate ones, but resulting object size in session was 14 KB. Could anyone explain me what is the difference between these two xdoclet and annotation mappings and why it has so significant impact on size of resulting PersistenSet ? thanks, jm. ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ hibernate-devel mailing list hibernate-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/hibernate-devel