-->
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.  [ 8 posts ] 
Author Message
 Post subject: property identifier "unique" not mapped in my sql
PostPosted: Tue Dec 23, 2008 9:50 am 
Newbie

Joined: Tue Dec 23, 2008 9:30 am
Posts: 14
hiiii
i need someone help please

i have a column that it has to be unique so in the mapping file i wrote :

<property
name="categoryName"
column="CATEGORYNAME_AT"
type="string"
unique="true"
/>

but when i go to mysql to see the tables created and check the CATEGORYNAME column i find the column option "primary key" not checked !!
so i need it to be unique but the option is not taken from the mapping file why???


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 24, 2008 2:41 am 
Newbie

Joined: Tue Dec 23, 2008 9:30 am
Posts: 14
plz any one has a suggestion ??
i don't know is the problem with the mysql version i am working on ??
just for notice i work under ubuntu environment


Top
 Profile  
 
 Post subject: Use<id> instead of property
PostPosted: Wed Dec 24, 2008 6:41 am 
Beginner
Beginner

Joined: Wed Nov 26, 2008 1:02 am
Posts: 22
Use <id>instead of <property> and generator class is 'uuid.hex',reason is you are using String as primay key,automatically it will be unique,and in database the primay key field should be this property.you will get content name column checked as primary key in table.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 24, 2008 9:13 am 
Newbie

Joined: Tue Dec 23, 2008 9:30 am
Posts: 14
so what unique = "true" does when added to a property???


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 24, 2008 9:21 am 
Beginner
Beginner

Joined: Wed Nov 26, 2008 1:02 am
Posts: 22
hi,
i will clarify this by an example,
create table(col1 varchar2 primaryKey, col2 varchar2 unique),

here col1 is primary key(notnull,unique),and col2 is also (unique) but not primary key, so for any unique constrained column may not be primary key,
so if u want a property to be checked as primary key option you must give it as <id>,then only primary key option will be checked in database.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 24, 2008 11:04 am 
Beginner
Beginner

Joined: Wed Apr 18, 2007 6:17 pm
Posts: 49
Location: Dominican Republic
I don't agree with Akumar1 because it's not necessary. You are able to define a property that it's unique and that it's not a primary key. h3a i've done this several times and worked fine for me. What's the version of mysql/hibernate/dialect/table engine are you using?

regards,


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 25, 2008 4:17 am 
Newbie

Joined: Tue Dec 23, 2008 9:30 am
Posts: 14
thx AKumar1

ataveras :
we r using MySQL5InnoDBDialect


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 06, 2009 3:37 am 
Newbie

Joined: Tue Dec 23, 2008 9:30 am
Posts: 14
so no solution for this


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