Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

The same old foreign key issue

 
Rashid Darvesh
Ranch Hand
Posts: 189
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am struggling with the same old foreing key issue. here is the issue
got a table
user table
user_id char(50) primary key

User_Detail table
user_name
user_phone
user_id references user(user_id)

here is the excerpts from the mapping file
<class name="com.hms.model.User" table="User">
<id name="userId" type="string" unsaved-value="null" >
<column name="user_id" sql-type="char(20)" not-null="true"/>
<generator class="assigned"/>
</id>
<property name="password">
<column name="password" />
</property>
<property name="userType">
<column name="user_type_id" />
</property>
<one-to-one name="userDetails" class="com.hms.model.UserDetails" cascade ="all" />
</class>



<class name="com.hms.model.UserDetails" table="user_details">

<id name="userId" column="user_id">
<generator class="foreign">
<param name="property">user</param>
</generator>
</id>
<one-to-one name="user" class="com.hms.model.User" constrained="true"/>
when i try to fetch the user object i get the following error.

org.hibernate.exception.SQLGrammarException: could not load an entity: [com.hms.model.User#aaa]
org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:67)
org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
org.hibernate.loader.Loader.loadEntity(Loader.java:1799)

Any help
Thanks
Rashid
 
Rashid Darvesh
Ranch Hand
Posts: 189
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello any help
Rashid
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic