Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Object Relational Mapping
Search Coderanch
Advance search
Google search
Register / Login
Win a copy of
Practice Tests for OCP Java 17 Certification Exam (1Z0-829)
this week in the
OCPJP
forum!
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Tim Cooke
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Liutauras Vilda
Sheriffs:
Rob Spoor
Junilu Lacar
paul wheaton
Saloon Keepers:
Stephan van Hulst
Tim Moores
Tim Holloway
Carey Brown
Scott Selikoff
Bartenders:
Piet Souris
Jj Roberts
fred rosenberger
Forum:
Object Relational Mapping
how to make the column unique?
jim li
Ranch Hand
Posts: 180
posted 14 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
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
Posts: 180
posted 14 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
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
Posts: 5006
1
I like...
posted 14 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
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.
@Entity public class User { private Long id; private String password; @Id @GeneratedValue public Long getId() { return id; } public void setId(Long id) { this.id = id; } public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } public static void main(String args[]) { AnnotationConfiguration config = new AnnotationConfiguration(); config.addAnnotatedClass(User.class); config.configure(); new SchemaExport(config).create(true, true); } }
-Cameron McKenzie
jim li
Ranch Hand
Posts: 180
posted 14 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
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
Posts: 180
posted 14 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
hi
i got the problem
in stead of using new SchemaExport(config).create(true, true);
i used new SchemaExport(config).drop(true, true);
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Show Distinct values from excel column using POI
How can I use many-to-one without foreign-key
How to generate a unique ID?
Hibernate Unique Statement
Unique constraint issue ...
More...