-->
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: Do I have to map a PK?
PostPosted: Tue Nov 18, 2008 5:59 am 
Newbie

Joined: Tue Nov 18, 2008 5:47 am
Posts: 5
Hi all,

My question is as subject. The reason being that the application I'm working on use a legacy DB, and the domain object created only need a few fields from the underlaying table, therefore, some of the PK columns are not presented in the domain object, not sure how to deal with this case.

And also when querying the object the condition will involve some of the fields that is not presented in the domain. Please advise, if hibernate is able to handle these kind of situations, or I have to go with JDBC.

Thanks in advance.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 18, 2008 7:31 am 
Regular
Regular

Joined: Wed Jun 20, 2007 1:53 am
Posts: 75
As Identity for an object is mandatory to identify the object uniquely, so I don't think Hibernate will allow to do mapping without primary key, generally it is not recomended to design the object without identity(PK),

But in your case you are working with lagecy database, so that may requires domain object without primary key.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 19, 2008 7:18 am 
Newbie

Joined: Tue Nov 18, 2008 5:47 am
Posts: 5
Thanks for the reply, so that leaves me no choice without changing the domain object, have to go with JDBC then.


Top
 Profile  
 
 Post subject: Re: Do I have to map a PK?
PostPosted: Wed Nov 19, 2008 8:31 am 
Beginner
Beginner

Joined: Wed Nov 19, 2008 8:25 am
Posts: 46
Location: Saint Petersburg, Russian Federation
fmz wrote:
domain object created only need a few fields from the underlaying table, therefore, some of the PK columns are not presented in the domain object, not sure how to deal with this case.

And also when querying the object the condition will involve some of the fields that is not presented in the domain.


Relation between database data and domain objects is not clear. Am I right assuming that you just create domain objects on the stored data basis (not including all PK information)? Do you need to change domain object state and persist them after that or all you need is just to load particular data and don't bother with saving its updated state?


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.