-->
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.  [ 5 posts ] 
Author Message
 Post subject: No Primary Key
PostPosted: Tue Jun 17, 2008 2:27 am 
Newbie

Joined: Tue Jun 17, 2008 2:10 am
Posts: 2
I had one table that has no primary key .But Hibernate takes all columns as composite primary keys and generated 2 POJOs .
when Iam retrieving the records from that table the query is executed correctly ,ie Iam getting exact list size but result set is showing null.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 17, 2008 10:06 am 
Expert
Expert

Joined: Thu May 26, 2005 9:19 am
Posts: 262
Location: Oak Creek, WI
Your code would help us....

_________________
RamnathN
Senior Software Engineer
http://www.linkedin.com/in/ramnathn
Don't forget to rate.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 17, 2008 3:23 pm 
Expert
Expert

Joined: Tue May 13, 2008 3:42 pm
Posts: 919
Location: Toronto & Ajax Ontario www.hibernatemadeeasy.com
What part of the result is null?

_________________
Cameron McKenzie - Author of "Hibernate Made Easy" and "What is WebSphere?"
http://www.TheBookOnHibernate.com Check out my 'easy to follow' Hibernate & JPA Tutorials


Top
 Profile  
 
 Post subject: No Primary Key
PostPosted: Wed Jun 18, 2008 12:11 am 
Newbie

Joined: Tue Jun 17, 2008 2:10 am
Posts: 2
ramnath wrote:
Your code would help us....


I had Scheme table that has no primary key .It had 3 fields
schemeCode,schemeName,schemeRate.The hibernate-reveng.xml file
created 2 POJOS.ie Scheme.java,SchemeId.java.
The code for Scheme.java like this-----
private SchemeId id;

public Scheme() {
}

public Scheme(SchemeId id) {
this.id = id;
}
//getter& setter for id property

The code for SchemeId.java like this-----

private String schemeCode;
private String schemeName;
private BigDecimal schemeRate;
//getter& setters for above 3 properties

I am trying to execute query ie like this
sql="from Scheme obj where obj.id.schemeCode='A002'"
qry=session.createQuery(sql);
Output of qry.list() showing null
But

qry.list.size()------It showing correct list size


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 18, 2008 9:54 am 
Expert
Expert

Joined: Thu May 26, 2005 9:19 am
Posts: 262
Location: Oak Creek, WI
If i understand correctly..You get the list size but all the values in the objects are null..I hope you would have made an mistake in the mapping files...Can you post that too for us?

Did u generate the mapping file or you did it on your own?

_________________
RamnathN
Senior Software Engineer
http://www.linkedin.com/in/ramnathn
Don't forget to rate.


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

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.