This would be a problem with your dialect, the dialect for Oracle maps a guid as RAW(16). I'm not exactly sure on how to set it up to treat guids as strings instead, you could try asking on hibernate forums.
On Dec 17, 12:38 pm, Alex McMahon <[email protected]> wrote: > I've got 2 classes that use Guid as their Id. I want to enable a many > to many association between them. I'm working with a legacy Oracle > database that I can't change. > > I'm testing retrieval from the database and the associations are not > populated at all. > > Looking at the SQL that is generated it appears to be because the Guid > for one side of the relationship that is used as a "Where" parameter > is being converted into a hex string... Any Idea why this is > happening? > > I've tried various different generators in the Id mappings, but none > have solved the problem. The only way I've got it to work has been to > use FetchyType.SubSelect() as this used a Where xxx In(Select...) so > the Guid wasn't used. > > The Database is defined to use Varchar2(36 byte) for all the Guid > columns. > > public class Role > { > public virtual Guid Id > { > get; > set; > } > > public virtual IList<Permission> Permissions > { > get; > set; > } > } > > public class Permission > { > public virtual Guid Id > { > get; > set; > } > > public virtual IList<Role> Roles > { > get; > set; > } > } > > public PermissionMap() > { > Table("Permission"); > Id(x => x.Id, "Permission_Id"); > HasManyToMany(x => x.Roles) > .Table("Role_Permission") > .ParentKeyColumn("Permission_Id") > .ChildKeyColumn("Role_Id") > .Inverse(); > } > > public RoleMap() > { > Table("Role"); > Id(x => x.Id, "Role_Id"); > HasManyToMany(x => x.Permissions) > .Table("Role_Permission") > .ParentKeyColumn("Role_Id") > .ChildKeyColumn("Permission_Id"); > } > > NHibernate: SELECT this_.Role_Id as Role1_3_0_, this_.Name as > Name3_0_, this_.Description as Descript3_3_0_ FROM Role this_ > NHibernate: SELECT permission0_.Role_Id as Role2_1_, > permission0_.Permission_Id as Permission1_1_, > permission1_.Permission_Id as Permission1_1_0_, > permission1_.Description as Descript2_1_0_ FROM Role_Permission > permission0_ left outer join Permission permission1_ on > permission0_.Permission_Id=permission1_.Permission_Id WHERE > permission0_.Role_Id=:p0;:p0 = 0x443833854E8EEE488808CDFBA10E44AD -- You received this message because you are subscribed to the Google Groups "Fluent NHibernate" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/fluent-nhibernate?hl=en.
