-->
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.  [ 4 posts ] 
Author Message
 Post subject: database view -> POJO
PostPosted: Tue Nov 22, 2005 12:53 am 
Newbie

Joined: Tue Nov 22, 2005 12:47 am
Posts: 6
Hi, has anyone tried mapping a database view into a Hibernate POJO Object?.
I have a situation here wherein, once I retrieved the list of objects from my
hibernate query and Iterate over it,
the result is that, I got the correct size of the List but the List only contain the same data objects!.

why is this happened?.
is there anything that I need to take care about when mapping VIEWS to Hibernate?

Thanks in advance.
Troy


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 22, 2005 1:31 am 
Expert
Expert

Joined: Mon Jul 04, 2005 5:19 pm
Posts: 720
you may want ot revisit your hashCode() and equals() implementations - although the view vs. table thing is an entirely different issue.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 22, 2005 2:01 am 
Expert
Expert

Joined: Thu May 26, 2005 9:19 am
Posts: 262
Location: Oak Creek, WI
Hi

Consider this as the Scenario
Table A : id, name , value are the column
Table B : id, description, address are the column

So now i create a view called
View C : with A.id = B.id; with all columns

What i have done is.
I have created a new Model object for the view as
Class C{

private int id;
private String name;
private int value;
private String description;
private String address;

and Getters/Setters here

}

I have create a new mapping file for the view and use this Model Object C to get the value.

DID THIS ANSWER UR QUESTION?

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


Top
 Profile  
 
 Post subject: view --> POJO
PostPosted: Tue Nov 22, 2005 5:30 am 
Newbie

Joined: Tue Nov 22, 2005 12:47 am
Posts: 6
I have solved the problem regarding the issue before i read your responses.
I tried searching the entire forum for some answers and I bumped into one posting that mentioned about making a <composite-id> element into the xml mapping and making a POJO to implement Serializable interface and override both the equals() and hashCode() methods which I just did and it works!!!

Anyways, thanks to both of you guys for exerting efforts to help me out here.

David, I should have given you credits but I have read your posting a little late. Thank you anyways!.

Cheers.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.