Open
Description
hasan uzun created an issue — 21st February 2015, 14:14:31:
Here is the hbm file for my table:
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="Yente.Membership.Domain" namespace="Yente.Membership.Domain.BO"> <class name="UserRole" table="User_Roles" optimistic-lock="version" polymorphism="explicit" > <id name="ID" column="User_Role_Id" type="long" unsaved-value="0"> <generator class="native"> <param name="sequence">User_Roles_Seq</param> </generator> </id> <version name="Version" column="Version" unsaved-value="0" type="int"/> <many-to-one name="Role" class="Role" column="Role_Id" foreign-key="User_Roles_Role_FK"></many-to-one> <many-to-one name="User" class="User" column="User_Id" foreign-key="User_Roles_User_FK"></many-to-one> </class> </hibernate-mapping>and here is the created table:
CREATE TABLE User_Roles ( User_Role_Id BIGINT not null, Version INT not null, Role_Id integer primary key autoincrement, User_Id BIGINT, constraint User_Roles_Role_FK foreign key (Role_Id) references Roles, constraint User_Roles_User_FK foreign key (User_Id) references Users )
Alexander Zaytsev added a comment — 11th December 2015, 8:25:33:
-[~hascaykas] can you please explain what's wrong?-
hasan uzun added a comment — 12th December 2015, 11:20:50:
Hi Alexander Zaytsev, I think the bug is clear in the title. The created primary key is wrong. UserRole_Id must be defined as primary key but it sets the foreign key RoleId as primary key.
Alexander Zaytsev added a comment — 14th December 2015, 8:31:33:
[~hascaykas] I asked and then realized what's wrong. Sorry for the inconveniences.