*
The moose likes Object Relational Mapping and the fly likes how to make the column unique? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "how to make the column unique?" Watch "how to make the column unique?" New topic
Author

how to make the column unique?

jim li
Ranch Hand

Joined: May 20, 2008
Posts: 180
hi guys

i have a primary key in my table, but for my code column i want it to be unique. how can i do this?

thank you
jim li
Ranch Hand

Joined: May 20, 2008
Posts: 180
i solve the problem!!

but do you guys know how to delete the whole table from data base by hibernate
session?

thank you
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper

Joined: Aug 26, 2006
Posts: 4968
    
    1



If you pass the SchemaExport class a config object that has nothing in it, and run the create method on the SchemaExport class, it will drop all the tables in the database.




-Cameron McKenzie
jim li
Ranch Hand

Joined: May 20, 2008
Posts: 180
hi

i just clean the the data information from the table, but it does not drop the tables?

the below is my xml file:
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC "221.221.221.73-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="connection.url">
*
</property>
<property name="hibernate.show_sql">
*
</property>
<property name="connection.driver_class">
*
</property>
<property name="connection.username">
*
</property>
<property name="connection.password">
*
</property>
<!-- Set AutoCommit to true -->
<property name="connection.autocommit">
true
</property>
<!-- SQL Dialect to use. Dialects are database specific -->
<property name="dialect">
org.hibernate.dialect.Oracle10gDialect
</property>
<property name="hibernate.hbm2ddl.auto">
update
</property>
<!-- Mapping files -->
<mapping class="com.blinco.wave3x.account.Division"/>
<mapping class="com.blinco.wave3x.account.Department"/>
<mapping class="com.blinco.wave3x.account.UserGroup"/>
<mapping class="com.blinco.wave3x.account.UserInfo"/>
<mapping class="com.blinco.wave3x.account.Company"/>
<mapping class="com.blinco.wave3x.account.CompanyType"/>
<mapping class="com.blinco.wave3x.account.Country"/>
<mapping class="com.blinco.wave3x.account.State"/>
<mapping class="com.blinco.wave3x.app.App"/>
<mapping class="com.blinco.wave3x.app.Module"/>
<mapping class="com.blinco.wave3x.app.Bookmark"/>
<mapping class="com.blinco.wave3x.app.UserRating"/>
<mapping class="com.blinco.wave3x.app.Permission"/>
</session-factory>
</hibernate-configuration>
jim li
Ranch Hand

Joined: May 20, 2008
Posts: 180
hi

i got the problem

in stead of using new SchemaExport(config).create(true, true);

i used new SchemaExport(config).drop(true, true);
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to make the column unique?
 
Similar Threads
Hibernate Unique Statement
Show Distinct values from excel column using POI
How can I use many-to-one without foreign-key
Unique constraint issue ...
How to generate a unique ID?