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

how to map column if there is no relationship??

 
gopal kishan
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I dont know how to map columns if there is no relations ship.

table1 contains clientid, clientname, status,customerid

table 2 contains customerid, customername

i want to display table1 columns, with customer name but there is no relationship in these 2 tables. so how will u map the customer name ???

i define like these. and geter and setter
private Table2 customer;

in Table1 mapping file in xml i mapped like
<property name="customer" type="com.test.model.Table2" column="CUSTOMER_ID"/>

but i am not getting values it shows could not read column value from result set
how to get customer name???
 
mysha ahamed
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
u shuld associate the two classes using <one-to-many > or<many-to-many> in hbm file
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Though you shouldn't really ever define an association where there is no relationship (not that Hibernate will stop you). If the data is not related, there is no constraint to keep it valid. What happens for example if a customer is deleted?

That being said if you have a customerid field in client, why is there no foreign key constraint?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic