i'm trying create 1 entity 2 tables related not primary key
tables:
create table [employees]( [ssn] [nvarchar](9) null, [active] [bit] null, [employee_id] [int] identity(1,1) not null ) create table [sam_employees]( [ssn] [nvarchar](9) null, [first_name] [nvarchar](50) null, [last_name] [nvarchar](50) null, [skill] [nvarchar](50) null, .... ) sql generate:
select this_.employee_id employee1_0_0_, this_.ssn ssn0_0_, this_.active active0_0_, this_1_.first_name first2_1_0_, this_1_.last_name last3_1_0_, this_1_.skill skill1_0_ employees this_ inner join sam_employees this_1_ on this_.ssn = this_1_.ssn this_.active = 1 my current mapping:
public class employeemap : classmap<employee> { public employeemap() { table("employees"); id(x => x.id, "employee_id"); map(x => x.ssn, "ssn"); map(x => x.isactive, "active"); join("sam_employees", mm => { mm.keycolumn("ssn"); mm.map(xx => xx.firstname, "first_name"); mm.map(xx => xx.lastname, "last_name"); mm.map(xx => xx.skill, "skill"); }); } } but mapping have such join condition on this_.employee_id = this_1_.ssn
i know question asked before didn't find answer it, workaround use view in database side instead of tables.
you can try mapping sam_employees entity , use references mapping join type fetch.
Comments
Post a Comment