-->
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.  [ 3 posts ] 
Author Message
 Post subject: Non repeated properties
PostPosted: Sun Aug 21, 2005 11:09 am 
Beginner
Beginner

Joined: Thu Jul 14, 2005 10:11 am
Posts: 32
Hello,

i'm kind of new with hibernate... and... i was wondering...

is there a way to avoid having a repeated propertie in a table ??. For instance, the 'Users' class, shouldn't have any LOGIN repeated.

I can do it with a simply SELECT, and check it myself. But, does Hibernate have some function to ease the job ?

Thank you!!


Top
 Profile  
 
 Post subject:
PostPosted: Sun Aug 21, 2005 7:15 pm 
Expert
Expert

Joined: Thu Dec 04, 2003 12:36 pm
Posts: 275
Location: Bielefeld, Germany
For saving your objects to the database your database column might be set to be unique.

Example:

Code:
<property name="loginName"
   column="loginname"
   type="string"
   not-null="true"
   unique="true"/>


This will avoid having to users with the same login name in the database.
Before saving a new user in the database you might check, if it already exists in order to avoid a unique constraint error of the database.

Best regards
Sven

_________________
Please don't forget to give credit, if this posting helped to solve your problem.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Aug 21, 2005 8:00 pm 
Beginner
Beginner

Joined: Thu Jul 14, 2005 10:11 am
Posts: 32
thanks!!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.