-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Joining Table w/o Primary/Foreign Key Relationship
PostPosted: Thu Aug 23, 2007 10:04 pm 
Newbie

Joined: Thu Aug 23, 2007 9:52 pm
Posts: 9
I am new to Hibernation and facing an issue.

I have Table1 and Table2 . Table1 has filed "server" and Table2 has field "machine" . Both means same thing(Can't change schema)

I have a many to one relationship from Table1 to Table 2.

class CTable1 {
@OneToMany
@JoinColumn(name ="server") //XXX could be the problem
private List<CTable2> list;

//get and set for list
}

class CTable2 {
@Id @GeneratedValue
@Column(name="ID")
private Integer id;

@Column(name="machine")
private Integer machine;

// get and set
}

I am getting run time exception when I am trying to call getList() fro CTable1
org.hibernate.exception.SQLGrammarException: could not initialize a collection: [com.company.zz.CTable1.list#1]

The above code works fine if column "machine" were named "server" in table2. Can some one please tell me how to create join when both table have different column names.

Thanks,


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.