title: Column 'x.Id' is not the same data type as referencing column 'y.xId'
body: <p>Its my user model</p>
  
  <pre><code>public class Users {
      private long id;
      private String userName;
      private String normalizedUserName;
      private String email;
      private String normalizedEmail;
      private boolean emailConfirmed;
      private String passwordHash;
      private String securityStamp;
      private String concurrencyStamp;
      private String phoneNumber;
      private boolean phoneNumberConfirmed;
      private boolean twoFactorEnabled;
      private Date lockoutEnd;
      private boolean lockoutEnabled;
      private int accessFailedCount;
      private long shopId;
      private Date registerDate;
  
      private Collection&lt;UserTokens&gt; userTokensById;
  
      public long getId() {
          return id;
      }
  
      public void setId(long id) {
          this.id = id;
      }
  
      public String getUserName() {
          return userName;
      }
  
      public void setUserName(String userName) {
          this.userName = userName;
      }
  
      public String getNormalizedUserName() {
          return normalizedUserName;
      }
  
      public void setNormalizedUserName(String normalizedUserName) {
          this.normalizedUserName = normalizedUserName;
      }
  
      public String getEmail() {
          return email;
      }
  
      public void setEmail(String email) {
          this.email = email;
      }
  
      public String getNormalizedEmail() {
          return normalizedEmail;
      }
  
      public void setNormalizedEmail(String normalizedEmail) {
          this.normalizedEmail = normalizedEmail;
      }
  
      public boolean isEmailConfirmed() {
          return emailConfirmed;
      }
  
      public void setEmailConfirmed(boolean emailConfirmed) {
          this.emailConfirmed = emailConfirmed;
      }
  
      public String getPasswordHash() {
          return passwordHash;
      }
  
      public void setPasswordHash(String passwordHash) {
          this.passwordHash = passwordHash;
      }
  
      public String getSecurityStamp() {
          return securityStamp;
      }
  
      public void setSecurityStamp(String securityStamp) {
          this.securityStamp = securityStamp;
      }
  
      public String getConcurrencyStamp() {
          return concurrencyStamp;
      }
  
      public void setConcurrencyStamp(String concurrencyStamp) {
          this.concurrencyStamp = concurrencyStamp;
      }
  
      public String getPhoneNumber() {
          return phoneNumber;
      }
  
      public void setPhoneNumber(String phoneNumber) {
          this.phoneNumber = phoneNumber;
      }
  
      public boolean isPhoneNumberConfirmed() {
          return phoneNumberConfirmed;
      }
  
      public void setPhoneNumberConfirmed(boolean phoneNumberConfirmed) {
          this.phoneNumberConfirmed = phoneNumberConfirmed;
      }
  
      public boolean isTwoFactorEnabled() {
          return twoFactorEnabled;
      }
  
      public void setTwoFactorEnabled(boolean twoFactorEnabled) {
          this.twoFactorEnabled = twoFactorEnabled;
      }
  
      public Date getLockoutEnd() {
          return lockoutEnd;
      }
  
      public void setLockoutEnd(Date lockoutEnd) {
          this.lockoutEnd = lockoutEnd;
      }
  
      public boolean isLockoutEnabled() {
          return lockoutEnabled;
      }
  
      public void setLockoutEnabled(boolean lockoutEnabled) {
          this.lockoutEnabled = lockoutEnabled;
      }
  
      public int getAccessFailedCount() {
          return accessFailedCount;
      }
  
      public void setAccessFailedCount(int accessFailedCount) {
          this.accessFailedCount = accessFailedCount;
      }
  
      public long getShopId() {
          return shopId;
      }
  
      public void setShopId(long shopId) {
          this.shopId = shopId;
      }
  
      public Date getRegisterDate() {
          return registerDate;
      }
  
      public void setRegisterDate(Date registerDate) {
          this.registerDate = registerDate;
      }
  
      @Override
      public boolean equals(Object o) {
          if (this == o) return true;
          if (o == null || getClass() != o.getClass()) return false;
          Users users = (Users) o;
          return id == users.id &amp;&amp;
                  emailConfirmed == users.emailConfirmed &amp;&amp;
                  phoneNumberConfirmed == users.phoneNumberConfirmed &amp;&amp;
                  twoFactorEnabled == users.twoFactorEnabled &amp;&amp;
                  lockoutEnabled == users.lockoutEnabled &amp;&amp;
                  accessFailedCount == users.accessFailedCount &amp;&amp;
                  shopId == users.shopId &amp;&amp;
                  Objects.equals(userName, users.userName) &amp;&amp;
                  Objects.equals(normalizedUserName, users.normalizedUserName) &amp;&amp;
                  Objects.equals(email, users.email) &amp;&amp;
                  Objects.equals(normalizedEmail, users.normalizedEmail) &amp;&amp;
                  Objects.equals(passwordHash, users.passwordHash) &amp;&amp;
                  Objects.equals(securityStamp, users.securityStamp) &amp;&amp;
                  Objects.equals(concurrencyStamp, users.concurrencyStamp) &amp;&amp;
                  Objects.equals(phoneNumber, users.phoneNumber) &amp;&amp;
                  Objects.equals(lockoutEnd, users.lockoutEnd) &amp;&amp;
                  Objects.equals(registerDate, users.registerDate);
      }
  
      @Override
      public int hashCode() {
          return Objects.hash(id, userName, normalizedUserName, email, normalizedEmail, emailConfirmed, passwordHash, securityStamp, concurrencyStamp, phoneNumber, phoneNumberConfirmed, twoFactorEnabled, lockoutEnd, lockoutEnabled, accessFailedCount, shopId, registerDate);
      }
  
  
  
      public Collection&lt;UserTokens&gt; getUserTokensById() {
          return userTokensById;
      }
  
      public void setUserTokensById(Collection&lt;UserTokens&gt; userTokensById) {
          this.userTokensById = userTokensById;
      }
  }
  </code></pre>
  
  <p>My userToken model have more than one pk so i have 2 class<br>
  its my UserTokens model</p>
  
  <pre><code>public class UserTokens implements Serializable {
      private long userId;
      private String loginProvider;
      private String name;
      private String value;
      private Date registerDate;
      private Users usersByUserId;
  
      public long getUserId() {
          return userId;
      }
  
      public void setUserId(long userId) {
          this.userId = userId;
      }
  
      public String getLoginProvider() {
          return loginProvider;
      }
  
      public void setLoginProvider(String loginProvider) {
          this.loginProvider = loginProvider;
      }
  
      public String getName() {
          return name;
      }
  
      public void setName(String name) {
          this.name = name;
      }
  
      public String getValue() {
          return value;
      }
  
      public void setValue(String value) {
          this.value = value;
      }
  
      public Date getRegisterDate() {
          return registerDate;
      }
  
      public void setRegisterDate(Date registerDate) {
          this.registerDate = registerDate;
      }
  
      @Override
      public boolean equals(Object o) {
          if (this == o) return true;
          if (o == null || getClass() != o.getClass()) return false;
          UserTokens that = (UserTokens) o;
          return userId == that.userId &amp;&amp;
                  Objects.equals(loginProvider, that.loginProvider) &amp;&amp;
                  Objects.equals(name, that.name) &amp;&amp;
                  Objects.equals(value, that.value) &amp;&amp;
                  Objects.equals(registerDate, that.registerDate);
      }
  
      @Override
      public int hashCode() {
          return Objects.hash(userId, loginProvider, name, value, registerDate);
      }
  
      public Users getUsersByUserId() {
          return usersByUserId;
      }
  
      public void setUsersByUserId(Users usersByUserId) {
          this.usersByUserId = usersByUserId;
      }
  }
  
  
  </code></pre>
  
  <p>and </p>
  
  <pre><code>public class UserTokensPK implements Serializable {
      private long userId;
      private String loginProvider;
      private String name;
  
      public long getUserId() {
          return userId;
      }
  
      public void setUserId(long userId) {
          this.userId = userId;
      }
  
      public String getLoginProvider() {
          return loginProvider;
      }
  
      public void setLoginProvider(String loginProvider) {
          this.loginProvider = loginProvider;
      }
  
      public String getName() {
          return name;
      }
  
      public void setName(String name) {
          this.name = name;
      }
  
      @Override
      public boolean equals(Object o) {
          if (this == o) return true;
          if (o == null || getClass() != o.getClass()) return false;
          UserTokensPK that = (UserTokensPK) o;
          return userId == that.userId &amp;&amp;
                  Objects.equals(loginProvider, that.loginProvider) &amp;&amp;
                  Objects.equals(name, that.name);
      }
  
      @Override
      public int hashCode() {
          return Objects.hash(userId, loginProvider, name);
      }
  }
  
  </code></pre>
  
  <p>Its my hbm user file </p>
  
  <pre><code>&lt;?xml version='1.0' encoding='utf-8'?&gt;
  &lt;!DOCTYPE hibernate-mapping PUBLIC
      "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
      "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"&gt;
  &lt;hibernate-mapping&gt;
  
      &lt;class name="oauth.identity.Model.Users" table="Users"&gt;
          &lt;id name="id"&gt;
              &lt;column name="Id" sql-type="bigint"/&gt;
          &lt;/id&gt;
          &lt;property name="userName"&gt;
              &lt;column name="UserName" sql-type="nvarchar(256)" length="256" not-null="true"/&gt;
          &lt;/property&gt;
          &lt;property name="normalizedUserName"&gt;
              &lt;column name="NormalizedUserName" sql-type="nvarchar(256)" length="256" not-null="true"/&gt;
          &lt;/property&gt;
          &lt;property name="email"&gt;
              &lt;column name="Email" sql-type="nvarchar(256)" length="256" not-null="true"/&gt;
          &lt;/property&gt;
          &lt;property name="normalizedEmail"&gt;
              &lt;column name="NormalizedEmail" sql-type="nvarchar(256)" length="256" not-null="true"/&gt;
          &lt;/property&gt;
          &lt;property name="emailConfirmed"&gt;
              &lt;column name="EmailConfirmed" sql-type="bit"/&gt;
          &lt;/property&gt;
          &lt;property name="passwordHash"&gt;
              &lt;column name="PasswordHash" sql-type="nvarchar(500)" length="500" not-null="true"/&gt;
          &lt;/property&gt;
          &lt;property name="securityStamp"&gt;
              &lt;column name="SecurityStamp" sql-type="nvarchar(500)" length="500" not-null="true"/&gt;
          &lt;/property&gt;
          &lt;property name="concurrencyStamp"&gt;
              &lt;column name="ConcurrencyStamp" sql-type="nvarchar(500)" length="500" not-null="true"/&gt;
          &lt;/property&gt;
          &lt;property name="phoneNumber"&gt;
              &lt;column name="PhoneNumber" sql-type="nvarchar(50)" length="50" not-null="true"/&gt;
          &lt;/property&gt;
          &lt;property name="phoneNumberConfirmed"&gt;
              &lt;column name="PhoneNumberConfirmed" sql-type="bit"/&gt;
          &lt;/property&gt;
          &lt;property name="twoFactorEnabled"&gt;
              &lt;column name="TwoFactorEnabled" sql-type="bit"/&gt;
          &lt;/property&gt;
          &lt;property name="lockoutEnd"&gt;
              &lt;column name="LockoutEnd" sql-type="datetime2" not-null="true"/&gt;
          &lt;/property&gt;
          &lt;property name="lockoutEnabled"&gt;
              &lt;column name="LockoutEnabled" sql-type="bit"/&gt;
          &lt;/property&gt;
          &lt;property name="accessFailedCount"&gt;
              &lt;column name="AccessFailedCount" sql-type="int"/&gt;
          &lt;/property&gt;
          &lt;property name="shopId"&gt;
              &lt;column name="ShopId" sql-type="bigint"/&gt;
          &lt;/property&gt;
          &lt;property name="registerDate"&gt;
              &lt;column name="RegisterDate" sql-type="datetime2"/&gt;
          &lt;/property&gt;
          &lt;set name="userTokensById" inverse="true"&gt;
              &lt;key&gt;
                  &lt;column name="UserId"/&gt;
              &lt;/key&gt;
              &lt;one-to-many not-found="ignore" class="oauth.identity.Model.UserTokens"/&gt;
          &lt;/set&gt;
      &lt;/class&gt;
  &lt;/hibernate-mapping&gt;
  </code></pre>
  
  <p>and hbm UserToken</p>
  
  <pre><code>&lt;hibernate-mapping&gt;
  
      &lt;class name="oauth.identity.Model.UserTokens" table="UserTokens"&gt;
          &lt;composite-id&gt;
              &lt;key-property name="loginProvider"&gt;
                  &lt;column name="LoginProvider" sql-type="nvarchar(256)" length="256"/&gt;
              &lt;/key-property&gt;
              &lt;key-property name="name"&gt;
                  &lt;column name="Name" sql-type="nvarchar(256)" length="256"/&gt;
              &lt;/key-property&gt;
          &lt;/composite-id&gt;
          &lt;property name="value"&gt;
              &lt;column name="Value" sql-type="nvarchar(4000)" length="4000" not-null="true"/&gt;
          &lt;/property&gt;
          &lt;property name="registerDate"&gt;
              &lt;column name="RegisterDate" sql-type="datetime2"/&gt;
          &lt;/property&gt;
          &lt;many-to-one name="usersByUserId" class="oauth.identity.Model.Users"&gt;
              &lt;column name="UserId"/&gt;
          &lt;/many-to-one&gt;
      &lt;/class&gt;
  &lt;/hibernate-mapping&gt;
  </code></pre>
  
  <p>and my application context </p>
  
  <pre><code> &lt;bean id="myDataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"&gt;
          &lt;property name="driverClassName" value="com.microsoft.sqlserver.jdbc.SQLServerDriver"/&gt;
          &lt;property name="url" value="jdbc:sqlserver://DPK-122\MSSQLSERVER2014;databaseName=SHC1;instanceName=MSSQLSERVER2014;"/&gt;
          &lt;property name="username" value="sa"/&gt;
          &lt;property name="password" value="password"/&gt;
      &lt;/bean&gt;
  
  
      &lt;bean id="mySessionFactory" class="org.springframework.orm.hibernate5.LocalSessionFactoryBean"&gt;
          &lt;property name="dataSource" ref="myDataSource"/&gt;
          &lt;property name="mappingResources"&gt;
              &lt;list&gt;
                  &lt;value&gt;Users.hbm.xml&lt;/value&gt;
                  &lt;value&gt;UserTokens.hbm.xml&lt;/value&gt;
              &lt;/list&gt;
          &lt;/property&gt;
          &lt;property name="hibernateProperties"&gt;
              &lt;props&gt;
                  &lt;prop key="hibernate.dialect"&gt;org.hibernate.dialect.SQLServerDialect&lt;/prop&gt;
                  &lt;prop key="hibernate.show_sql"&gt;true&lt;/prop&gt;
                  &lt;prop key="hibernate.hbm2ddl.auto"&gt;update&lt;/prop&gt;
              &lt;/props&gt;
          &lt;/property&gt;
  
      &lt;/bean&gt;
  
  
  </code></pre>
  
  <p>i think all thing is fine but it give me an error and dont work as excepted</p>
  
  <pre><code>Column 'Users.Id' is not the same data type as referencing column 'UserTokens.UserId' in foreign key 'FKe2l2gfho1gf1q3srduiy8owig'.
  </code></pre>
  
  <p>Both id type is big int i cant understand where is my fault ?</p>