-->
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: Unique columns
PostPosted: Wed Sep 06, 2006 8:57 am 
Newbie

Joined: Wed Sep 06, 2006 8:33 am
Posts: 19
Hi!

I have this table:
Code:
____________________
|  PESSOA          |
--------------------
| CPF              |
| NOME             |
| RG               |
| ORGAOEXPEDIDOR   |
| ORGAOEXPEDIDORUF |
--------------------

The column: CPF is a key, asigned by the user.
This columns: RG, ORGAOEXPEDIDOR and ORGAOEXPEDIDORUF are unique, but, this is not a "composite-id" with CPF.

How mapping this properties are unique?
I try to use the tag: <database-object to create the constraint:


Code:
alter table PESSOA
add constraint UNQ1_PESSOA
unique (RG,ORGAOEXPEDIDOR,ORGAOEXPEDIDORUF)


without success.

Any idea?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 06, 2006 9:33 am 
Newbie

Joined: Wed Sep 06, 2006 8:33 am
Posts: 19
I found in the nHibernate reference:

Quote:
Some tags accept an index attribute for specifying the name of an index for that column. A unique-key attribute
can be used to group columns in a single unit key constraint. Currently, the specified value of the uniquekey
attribute is not used to name the constraint, only to group the columns in the mapping file.


My mapping file:
Code:
      <property name="pCPF" type="Int32">
         <column name="CPF" unique-key="identidade"/>
      </property>
      <property name="pOrgaoExpedidor" type="string">
         <column name="OrgaoExpedidor"  unique-key="identidade"/>
      </property>
      <property name="pOrgaoExpedidorUF" type="string">
         <column name="OrgaoExpedidorUF" unique-key="identidade"/>
      </property>


Generated SQL for Postgre:
Code:
create table Pessoa( (...) unique (CPF, OrgaoExpedidor, OrgaoExpedidorUF));


Tks


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 20, 2006 2:43 pm 
Newbie

Joined: Sat Apr 08, 2006 11:45 am
Posts: 1
Kernel Panic wrote:
My mapping file:
Code:
      <property name="pCPF" type="Int32">
         <column name="CPF" unique-key="identidade"/>
      </property>
      <property name="pOrgaoExpedidor" type="string">
         <column name="OrgaoExpedidor"  unique-key="identidade"/>
      </property>
      <property name="pOrgaoExpedidorUF" type="string">
         <column name="OrgaoExpedidorUF" unique-key="identidade"/>
      </property>


Generated SQL for Postgre:
Code:
create table Pessoa( (...) unique (CPF, OrgaoExpedidor, OrgaoExpedidorUF));


Tks


Hi!

I have the same problem/question as you had!

In your solution-Post I don'd unterstand what the "identidade" property stands for?

Is this another must-existing property in this mapping file??

Please help!


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 20, 2006 2:47 pm 
Newbie

Joined: Wed Sep 06, 2006 8:33 am
Posts: 19
Hi!

'Identidade' is a identification of a person, compost by one integer, and two strings.
This tree columns is an 'Identidade', and, is unique....


Please, post a sample of your problem...


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.