-->
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.  [ 2 posts ] 
Author Message
 Post subject: regarding primary key
PostPosted: Mon Jul 07, 2008 9:27 am 
Newbie

Joined: Mon Jun 30, 2008 8:28 am
Posts: 2
Dear all,
i read hibernate will create the primary key automatically with mapping file(.hbm.xml)then why should we create the primary key while creating the table.

i creat the table like the following:
create table test(id int ,name varchar(10),sex varchar(10));

the hbm file is following:

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping>
<class name="com.re.test.keys.Testing" table="testing">
<id name="id" type="int" column="ID">
<generator class="increment"/>
</id>

<property name="name">
<column name="NAME" />
</property>
<property name="sex">
<column name="SEX"/>
</property>
</class>
</hibernate-mapping>

if i do it will create primary key automatically.anybody please help me



regards,
sathya


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 07, 2008 3:10 pm 
Expert
Expert

Joined: Tue May 13, 2008 3:42 pm
Posts: 919
Location: Toronto & Ajax Ontario www.hibernatemadeeasy.com
Well, if you're creating the table, you need to specify the primary key. If you don't, most databases won't even allow you to create the table.

What's the underlying issue you're having a problem with? It's not really an issue if you are creating the tables yourself. And it's not really an issue if you're letting Hibernate create the tables, right?

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