· 9 years ago · Nov 18, 2016, 05:02 PM
1<dependency>
2 <groupId>org.hibernate</groupId>
3 <artifactId>hibernate-core</artifactId>
4 <version>5.2.4.Final</version>
5</dependency>
6
7public class ExportDB {
8 public static void main(String[] args) {
9 ServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder().configure().build();
10 Metadata metadata = new MetadataSources(serviceRegistry).buildMetadata();
11 SchemaExport schemaExport = new SchemaExport();
12 schemaExport.create(EnumSet.of(TargetType.DATABASE), metadata);
13 }
14}
15
162016-11-19 00:22:12,845 WARN [org.hibernate.orm.connections.pooling] - HHH10001002: Using Hibernate built-in connection pool (not for production use!)
17Hibernate: drop table if exists hibernate_sequences
18Hibernate: drop table if exists user
19Hibernate: create table hibernate_sequences (sequence_name varchar(255) not null, sequence_next_hi_value bigint, primary key (sequence_name))
20Hibernate: create table user (id bigint not null, balance decimal(20,4) default 0.00, createTime time, displayName varchar(64), password varchar(64), username varchar(64), primary key (id))
21Hibernate: alter table user add constraint UK_7kuje5s4lbyq9qyv1r9ecm2it unique (username)
22
23MariaDB [cms]> show tables;
24+----------------+
25| Tables_in_cms |
26+----------------+
27| investor |
28+----------------+
291 row in set (0.00 sec)
30
31MariaDB [cms]> create table hibernate_sequences (sequence_name varchar(255) not null, next_val bigint, primary key (sequence_name));
32ERROR 1071 (42000): Specified key was too long; max key length is 767 bytes