Olá ,
como faço pra qdo chamar o main abaixo
crie no banco as tabelas mapeadas no arquivo persistence.xml
fiz essa configuração abaixo mas não mostra o create table no banco
se alguém puder me ajudar agradeceria…
abs
public class GeraBanco {
/**
* @param args
*/
public static void main(String[] args) {
System.out.println("Inicio...");
// TODO Auto-generated method stub
org.apache.log4j.BasicConfigurator.configure();
// Cria o banco.
Persistence.createEntityManagerFactory("JPA9");
System.out.println("Gerou...");
}
}
---
<persistence-unit name="JPA9">
<description>
Exemplo simples de persistência usando JPA.
</description>
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<class>br.com.exemplojpa.modelo.Universidade</class>
<class>br.com.exemplojpa.modelo.Centro</class>
<class>br.com.exemplojpa.modelo.Usuario</class>
<properties>
<property name="hibernate.archive.autodetetion" value="class"/>
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" />
<property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver" />
<property name="hibernate.connection.username" value="root" />
<property name="hibernate.connection.password" value="root" />
<property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/exemplojpa" />
<property name="hibernate.show_sql" value="true" />
<property name="hibernate.hbm2ddl.auto" value="create" />
</properties>
</persistence-unit>
---
--log4j.properties
# Set root category priority to INFO and its only appender to CONSOLE.
log4j.rootCategory=INFO, CONSOLE
log4j.rootCategory=INFO, CONSOLE, LOGFILE
Set the enterprise logger category to FATAL and its only appender to CONSOLE.
log4j.logger.org.apache.axis.enterprise=FATAL, CONSOLE
# CONSOLE is set to be a ConsoleAppender using a PatternLayout.
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
log4j.appender.CONSOLE.Threshold=INFO
log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
log4j.appender.CONSOLE.layout.ConversionPattern=- %m%n
# LOGFILE is set to be a File appender using a PatternLayout.
log4j.appender.LOGFILE=org.apache.log4j.FileAppender
log4j.appender.LOGFILE.File=axis.log
log4j.appender.LOGFILE.Append=true
log4j.appender.LOGFILE.Threshold=INFO
log4j.appender.LOGFILE.layout=org.apache.log4j.PatternLayout
log4j.appender.LOGFILE.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n
--
Inicio...
- Hibernate Annotations 3.3.1.GA
0 [main] INFO org.hibernate.cfg.annotations.Version - Hibernate Annotations 3.3.1.GA
- Hibernate 3.2.6
31 [main] INFO org.hibernate.cfg.Environment - Hibernate 3.2.6
- hibernate.properties not found
47 [main] INFO org.hibernate.cfg.Environment - hibernate.properties not found
- Bytecode provider name : cglib
63 [main] INFO org.hibernate.cfg.Environment - Bytecode provider name : cglib
- using JDK 1.4 java.sql.Timestamp handling
63 [main] INFO org.hibernate.cfg.Environment - using JDK 1.4 java.sql.Timestamp handling
- Hibernate EntityManager 3.3.2.GA
266 [main] INFO org.hibernate.ejb.Version - Hibernate EntityManager 3.3.2.GA
- Binding entity from annotated class: br.com.exemplojpa.modelo.Universidade
1236 [main] INFO org.hibernate.cfg.AnnotationBinder - Binding entity from annotated class: br.com.exemplojpa.modelo.Universidade
- Bind entity br.com.exemplojpa.modelo.Universidade on table Universidade
1346 [main] INFO org.hibernate.cfg.annotations.EntityBinder - Bind entity br.com.exemplojpa.modelo.Universidade on table Universidade
- Binding entity from annotated class: br.com.exemplojpa.modelo.Centro
1690 [main] INFO org.hibernate.cfg.AnnotationBinder - Binding entity from annotated class: br.com.exemplojpa.modelo.Centro
- Bind entity br.com.exemplojpa.modelo.Centro on table Centro
1690 [main] INFO org.hibernate.cfg.annotations.EntityBinder - Bind entity br.com.exemplojpa.modelo.Centro on table Centro
- Binding entity from annotated class: br.com.exemplojpa.modelo.Usuario
1706 [main] INFO org.hibernate.cfg.AnnotationBinder - Binding entity from annotated class: br.com.exemplojpa.modelo.Usuario
- Bind entity br.com.exemplojpa.modelo.Usuario on table Usuario
1706 [main] INFO org.hibernate.cfg.annotations.EntityBinder - Bind entity br.com.exemplojpa.modelo.Usuario on table Usuario
- Mapping collection: br.com.exemplojpa.modelo.Universidade.centros -> Centro
1909 [main] INFO org.hibernate.cfg.annotations.CollectionBinder - Mapping collection: br.com.exemplojpa.modelo.Universidade.centros -> Centro
- Hibernate Validator 3.0.0.GA
1940 [main] INFO org.hibernate.validator.Version - Hibernate Validator 3.0.0.GA
- Using Hibernate built-in connection pool (not for production use!)
2081 [main] INFO org.hibernate.connection.DriverManagerConnectionProvider - Using Hibernate built-in connection pool (not for production use!)
- Hibernate connection pool size: 20
2081 [main] INFO org.hibernate.connection.DriverManagerConnectionProvider - Hibernate connection pool size: 20
- autocommit mode: true
2081 [main] INFO org.hibernate.connection.DriverManagerConnectionProvider - autocommit mode: true
- using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql://localhost:3306/exemplojpa
2097 [main] INFO org.hibernate.connection.DriverManagerConnectionProvider - using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql://localhost:3306/exemplojpa
- connection properties: {user=root, password=****, autocommit=true, release_mode=auto}
2097 [main] INFO org.hibernate.connection.DriverManagerConnectionProvider - connection properties: {user=root, password=****, autocommit=true, release_mode=auto}
- RDBMS: MySQL, version: 5.0.67-community-nt
2488 [main] INFO org.hibernate.cfg.SettingsFactory - RDBMS: MySQL, version: 5.0.67-community-nt
- JDBC driver: MySQL-AB JDBC Driver, version: mysql-connector-java-5.0.0-beta ( $Date: 2005-11-17 16:14:47 +0100 (Thu, 17 Nov 2005) $, $Revision$ )
2504 [main] INFO org.hibernate.cfg.SettingsFactory - JDBC driver: MySQL-AB JDBC Driver, version: mysql-connector-java-5.0.0-beta ( $Date: 2005-11-17 16:14:47 +0100 (Thu, 17 Nov 2005) $, $Revision$ )
- Using dialect: org.hibernate.dialect.MySQLDialect
2535 [main] INFO org.hibernate.dialect.Dialect - Using dialect: org.hibernate.dialect.MySQLDialect
- Transaction strategy: org.hibernate.transaction.JDBCTransactionFactory
2550 [main] INFO org.hibernate.transaction.TransactionFactoryFactory - Transaction strategy: org.hibernate.transaction.JDBCTransactionFactory
- No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
2550 [main] INFO org.hibernate.transaction.TransactionManagerLookupFactory - No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
- Automatic flush during beforeCompletion(): disabled
2566 [main] INFO org.hibernate.cfg.SettingsFactory - Automatic flush during beforeCompletion(): disabled
- Automatic session close at end of transaction: disabled
2566 [main] INFO org.hibernate.cfg.SettingsFactory - Automatic session close at end of transaction: disabled
- JDBC batch size: 15
2566 [main] INFO org.hibernate.cfg.SettingsFactory - JDBC batch size: 15
- JDBC batch updates for versioned data: disabled
2566 [main] INFO org.hibernate.cfg.SettingsFactory - JDBC batch updates for versioned data: disabled
- Scrollable result sets: enabled
2566 [main] INFO org.hibernate.cfg.SettingsFactory - Scrollable result sets: enabled
- JDBC3 getGeneratedKeys(): enabled
2566 [main] INFO org.hibernate.cfg.SettingsFactory - JDBC3 getGeneratedKeys(): enabled
- Connection release mode: auto
2566 [main] INFO org.hibernate.cfg.SettingsFactory - Connection release mode: auto
- Maximum outer join fetch depth: 2
2566 [main] INFO org.hibernate.cfg.SettingsFactory - Maximum outer join fetch depth: 2
- Default batch fetch size: 1
2566 [main] INFO org.hibernate.cfg.SettingsFactory - Default batch fetch size: 1
- Generate SQL with comments: disabled
2566 [main] INFO org.hibernate.cfg.SettingsFactory - Generate SQL with comments: disabled
- Order SQL updates by primary key: disabled
2566 [main] INFO org.hibernate.cfg.SettingsFactory - Order SQL updates by primary key: disabled
- Order SQL inserts for batching: disabled
2566 [main] INFO org.hibernate.cfg.SettingsFactory - Order SQL inserts for batching: disabled
- Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
2566 [main] INFO org.hibernate.cfg.SettingsFactory - Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
- Using ASTQueryTranslatorFactory
2566 [main] INFO org.hibernate.hql.ast.ASTQueryTranslatorFactory - Using ASTQueryTranslatorFactory
- Query language substitutions: {}
2566 [main] INFO org.hibernate.cfg.SettingsFactory - Query language substitutions: {}
- JPA-QL strict compliance: enabled
2582 [main] INFO org.hibernate.cfg.SettingsFactory - JPA-QL strict compliance: enabled
- Second-level cache: enabled
2582 [main] INFO org.hibernate.cfg.SettingsFactory - Second-level cache: enabled
- Query cache: disabled
2582 [main] INFO org.hibernate.cfg.SettingsFactory - Query cache: disabled
- Cache provider: org.hibernate.cache.NoCacheProvider
2582 [main] INFO org.hibernate.cfg.SettingsFactory - Cache provider: org.hibernate.cache.NoCacheProvider
- Optimize cache for minimal puts: disabled
2582 [main] INFO org.hibernate.cfg.SettingsFactory - Optimize cache for minimal puts: disabled
- Structured second-level cache entries: disabled
2582 [main] INFO org.hibernate.cfg.SettingsFactory - Structured second-level cache entries: disabled
- Echoing all SQL to stdout
2597 [main] INFO org.hibernate.cfg.SettingsFactory - Echoing all SQL to stdout
- Statistics: disabled
2597 [main] INFO org.hibernate.cfg.SettingsFactory - Statistics: disabled
- Deleted entity synthetic identifier rollback: disabled
2597 [main] INFO org.hibernate.cfg.SettingsFactory - Deleted entity synthetic identifier rollback: disabled
- Default entity-mode: pojo
2597 [main] INFO org.hibernate.cfg.SettingsFactory - Default entity-mode: pojo
- Named query checking : enabled
2597 [main] INFO org.hibernate.cfg.SettingsFactory - Named query checking : enabled
- Hibernate Search 3.0.1.GA
2644 [main] INFO org.hibernate.search.Version - Hibernate Search 3.0.1.GA
- building session factory
2754 [main] INFO org.hibernate.impl.SessionFactoryImpl - building session factory
- Not binding factory to JNDI, no JNDI name configured
3380 [main] INFO org.hibernate.impl.SessionFactoryObjectFactory - Not binding factory to JNDI, no JNDI name configured
- Running hbm2ddl schema export
3411 [main] INFO org.hibernate.tool.hbm2ddl.SchemaExport - Running hbm2ddl schema export
- exporting generated schema to database
3411 [main] INFO org.hibernate.tool.hbm2ddl.SchemaExport - exporting generated schema to database
- schema export complete
4037 [main] INFO org.hibernate.tool.hbm2ddl.SchemaExport - schema export complete
Gerou...