aspose file tools*
The moose likes Object Relational Mapping and the fly likes Problem with Sybase stored proc in hibernate Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Problem with Sybase stored proc in hibernate" Watch "Problem with Sybase stored proc in hibernate" New topic
Author

Problem with Sybase stored proc in hibernate

pramodh somashekara
Ranch Hand

Joined: Jan 30, 2006
Posts: 62
I have a problem in accessing resultset from Sybase stored procedure. It is displaying ONLY the first row of the resultset.

The mapping file is



The stored proc contains only the SELECT statement on three tables.

The hibernate tells correctly the size of the resultset when I use size() on the result list. But when I try to display, it displays only the FIRST ROW SO MANY NUMBER OF TIMES.

Let us say, the query gives 3 rows, then hibernate gives size as 3 but displays FIRST ROW, THREE TIMES.

Can anybody tell about this problem?

Pramodh

[ Edited to use code tags - Paul Sturrock ]
[ December 15, 2006: Message edited by: Paul Sturrock ]
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Can you tell us more about the procedure and the data it returns? Does the procedure work OK ouside of Hibernate? Is the key that identifies each row in the results set (wbUserGrpId) unique within the result set?


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
pramodh somashekara
Ranch Hand

Joined: Jan 30, 2006
Posts: 62
The procedure works fines outside hibernate...the column(wbUserGrpId) is NOT unique within resultset.
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

There is your problem. Hibernate maps relational data. Relational data by definition must have a unique identifier: any entity without a primary key cannot be uniquely indentified and so cannot form part of a relationship. So every mapped object must have a primary key. Can you cahnge your procedure so it uniquely identifies each row, possibly by returning a surrogate key with each result?
[ December 15, 2006: Message edited by: Paul Sturrock ]
pramodh somashekara
Ranch Hand

Joined: Jan 30, 2006
Posts: 62
I made the changes to the proc and workign fine....thanks
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Problem with Sybase stored proc in hibernate