Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / October 2005

Tip: Looking for answers? Try searching our database.

hibernate question

Thread view: 
gk - 06 Oct 2005 14:33 GMT
in hibernate
(http://www.hibernate.org/hib_docs/v3/reference/en/html/tutorial.html)

there is a class

import java.util.Date;

public class Event {
   private Long id; // i dont have a coulmn with name "id" in my
DB...should i keep this ?

   private String title;
   private Date date;
Chris Smith - 06 Oct 2005 19:08 GMT
> in hibernate
> (http://www.hibernate.org/hib_docs/v3/reference/en/html/tutorial.html)
[quoted text clipped - 9 lines]
>     private String title;
>     private Date date;

What is the primary key for the database table, then?  You'll need some
kind of primary key for any table that is mapped as a Hibernate entity.  
You will also need a field in the corresponding class, which will
contain that database attribute.

The names don't matter, if that's what you're asking.  In the mapping
file, you can specify the name of the field and the name of the database
attribute, and they do not need to match.

Signature

www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation

gk - 07 Oct 2005 01:50 GMT
so,that means , if i have 5 columns in the DB . then class  should have
5 member variable . no less no more . correct ?

in fact , i was asking whether  this "id" has to be added as a
additional thing apart from the DB columns.

but as you told ,  there is no additional member variable . all
represents the DB column. so it is fine.

Thank you
Adam Maass - 07 Oct 2005 03:57 GMT
> so,that means , if i have 5 columns in the DB . then class  should have
> 5 member variable . no less no more . correct ?

No, not exactly. For the simpler cases, this is generally true. But you
could have multiple columns in the database, represented by a single object
in memory: columns STREET, CITY, ZIP might map to a single class Address.
Likewise, you might not bother to map some of the columns; maybe you don't
need them in memory for what you want to do.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.