• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

The same old foreign key issue

 
Ranch Hand
Posts: 189
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hello any help
Rashid
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic